cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Merge all Webservices of one Processgroup

Hi,

I have the requirement to merge all webservices within one processgroup. First I tried to use the merge service option within the ui settings. After discussion with the support it was clear that only services of type "Web Request Services" can be merged.

Then I found this post https://www.dynatrace.com/news/blog/new-dynatrace-api-enhances-automatic-service-detection-part-2/ by @Michael K. Is it possible to merge web services with the help of process group tags with this API? I tried something like the following, but it only returned me Internal Server Error....


{
  "type": "FULL_WEB_SERVICE",
  "name": "dynatrace service",
  "description": "merge resources of dynatrace service",
  "enabled": true,
  "detectAsWebRequestService": true,
  "conditions": [
    {
      "attributeType": "PG_TAG",
      "compareOperations": [
        {
          "type": "TAG",
          "tags": [
            {
                "key":"test"
            }
          ]
        }
      ]
    }
  ]
}


thx

Gerald

4 REPLIES 4

Julius_Loman
DynaMight Legend
DynaMight Legend

I think this really depends on which service types you have and how they are detected.

Basically you can modify or add the service properties such as context root, application id and server name. The rules will apply on services with a condition.

The approach I would take is to check the service types and their metadata (context root, application id, server name). Then determine the values that need to be changed.
For example - if your server names differ between service instances - you either use transformation rules to extract the right value or use the valueOverride to set a fixed value.

Remember:

  • you can use only the original value with transformation rules (you cannot use other metadata)
  • you can only merge services of the same type (you can't merge RMI service and full web request)


Here is, for example, one rule I used recently - the services to be merged differed in the server name (the server name property in the service metadata). So in this example for each full web request service where the server begins with soa this rule sets the server name to the value extracted from the detected server name metadata up to the first occurrence of the character "m":

{
  "type": "FULL_WEB_REQUEST",
  "metadata": {
    "configurationVersions": [
      0
    ],
    "clusterVersion": "1.186.78.20200212-151447"
  },
  "managementZones": [],
  "id": "8fd1ae6a-d223-4e67-953d-d99a629cb8ab",
  "name": "Merge",
  "description": "Merge Rule\n",
  "enabled": true,
  "conditions": [
    {
      "attributeType": "SERVER_NAME",
      "compareOperations": [
        {
          "type": "STARTS_WITH",
          "negate": false,
          "ignoreCase": true,
          "values": [
            "soa"
          ]
        }
      ]
    }
  ],
  "applicationId": null,
  "contextRoot": null,
  "serverName": {
    "transformations": [
      {
        "type": "BEFORE",
        "delimiter": "m"
      }
    ],
    "valueOverride": null
  }
}


Process group tags should work in recent server version, I believe the right format is (I'd add compareKeyOnly attribute to the operation if necessary in your case):

  "conditions": [
          {
                "attributeType": "PG_TAG",
                "compareOperations": [
                        {
                        "type": "TAG",
                        "tags": [ {
                                "key": "Component",
                                "value": "xxx"
                        } ]
                        }
                ]
          }
 


The documentation needs significant improvement in the area of compare operations.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Hi @Julius L.


Thank you for the quick response. Now I was able to create the new rule, but still it doesn't do anything ...

So actually I have the same usecase as described in the blog post. I want to merge all springboot REST-Services of one springboot deployment. In my example I have this Process Group which is equal to my springboot application:


Dynatrace comes up with those two services, which are detected because of the two Rest-Resources


Both of them are of type web service. So what I tried was similiar to the blog post but instead of the technology I want to use my tags for merging:


{
  "type": "FULL_WEB_SERVICE",
  "name": "dynatrace service",
  "description": "merge resources of dynatrace service",
  "enabled": true,
  "detectAsWebRequestService": true,
  "conditions": [
    {
      "attributeType": "PG_TAG",
      "compareOperations": [
        {
          "type": "TAG",
          "tags": [
            {
                "context": "KUBERNETES",
                "key":"[kubernetes]eosapp",
                "value":"dynatrace-0-1-0"
            }
          ]
        }
      ]
    }
  ]
}


I also tried the same solution as in @Michael K. blog post. There I encountered that the original services didn't receive new values, but I couldn't find a new merged service.


{
  "type": "FULL_WEB_SERVICE",
  "name": "Don't detect Jersey as WebService",
  "description": "REST API example",
  "enabled": true,
  "detectAsWebRequestService": true,
  "conditions": [
    {
      "attributeType": "FRAMEWORK",
      "compareOperations": [
        {
          "type": "EQUALS",
   
       
          "values": [
            "JERSEY"
          ]
        }
      ]
    },{
      "attributeType": "URL_PATH",
      "compareOperations": [
        {
          "type": "STARTS_WITH",
   
       
          "values": [
            "/api/"
          ]
        }
      ]
    }
  ]
}

Ah now it works. In the last try I had a copy paste error. I added the context to the tag correctly but missed to remove it from the name.


So this solution now works to merge all web services into one web request service for the given process group:


{
  "type": "FULL_WEB_SERVICE",
  "name": "dynatrace service",
  "description": "merge resources of dynatrace service",
  "enabled": true,
  "detectAsWebRequestService": true,
  "conditions": [
    {
      "attributeType": "PG_TAG",
      "compareOperations": [
        {
          "type": "TAG",
          "tags": [
            {
      "context": "KUBERNETES",
      "key": "eosapp",
      "value": "dynatrace-0-1-0"
    }
          ]
        }
      ]
    }
  ]
}


@Julius L. Thank you again, that helped to understand the whole thing a bit better 🙂

@Gerald M. you are welcome 🙂

The documentation for service detection API needs really an improvement. Especially for the conditions as this area is almost undocumented.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Featured Posts