Service detection rules

When monitoring with OneAgent, your deployed applications and related microservices are automatically detected by Dynatrace, based on specific properties of your application deployment and configuration, such as the application identifier, part of the URL, or the server name.

Attributes used for detection are marked with an asterisk ✱ on the service overview page, under Properties and tags.

In certain cases, the quality of data available to Dynatrace might be insufficient for high-precision service detection. To tailor out-of-the-box detection to your environment, you can create new rules or setup improvements.

Manage rule-based service detection

You can use transformation rules, for example, to remedy the following use cases:

  • If the web Application IDs contain the version or build date, you can define a rule that removes the build date/ID from the web application ID.

  • When server names are not properly defined in the underlying deployment (for example, with Apache HTTP or Nginx in AWS environments), you can define a stable web server name and therefore a stable cluster service containing all instances.

  • You can correct the misuse of the context root in the deployed application.

    A typical web server has a concept called the context root to separate services based on the URL. For some technologies, such as Node.js, the context root is not available or it's improperly defined. You can superimpose the context root, and create separate services for each of your applications, instead of a single service containing multiple applications.

  • You can ignore the port for service detection. This is helpful when the port is used dynamically, for example, in Node.js applications.

Additionally, the rules can be exported and imported from one environment to another.

Detection rules are evaluated from top to bottom, and the first matching rule applies, so be sure to place your rule in the correct position on the list.

Prerequisites

Create a rule

When you define a new rule, depending on the configuration, the original services might get less traffic or no traffic at all. New monitoring data is then redirected according to the rule configuration, between the original and the newly detected services.

Modify a rule

When you modify a rule, some services might not be affected by it anymore. While historical data is available only for the previous service, all newly captured data is then associated with the new standalone service.

Delete a rule

If you delete a rule, all individual services are split and once again treated as standalone services.

Examples

Separate fully monitored web request services based on URL or superimposed context root

For some technologies monitored by Dynatrace, the context root is not supported. A single service per process group is detected by default. You can change service detection by imposing a context root on a fully monitored web request.

In this example, when the URL path of a full web request starts with specific wording (blog/), we want to detect a service, whose ID will be transformed to the first segment of the URL.

Merge application data into a single service, based on the application ID value

When incoming data is volatile or not specific enough, you can use service detection rules to merge services, for example, Apache HTTP clusters in AWS without a proper virtual host or web application IDs containing the build date.

In this example, we want to merge in the same service all incoming data from applications whose ID starts with application.

Separate services for “public network services” based on URL

In this example, when the top-level domain of an external web request ends with a specific wording (dynatrace.com), we want to detect a service, whose ID will be transformed to the first segment of the URL.

You can pair this configuration with

Separate services for “public network services” based on subdomains

If different endpoints shouldn’t be combined in the same service (for example, support.dynatrace.com and blog.dynatrace.com), you can instruct Dynatrace to detect multiple services from the same domain, based on the detected hostname instead of the request's domain name.

Separate services for unmonitored hosts based on hostname or IP range

Similarly to how you can add information about requests to third-party domains, you can tell Dynatrace more about services to unmonitored hosts and also check against the called IP addresses.

In this example, the service Single Sign On is behind all requests to the IP range 211.44.94.0–212.113.5.0. Dynatrace retains information about the multiple IPs in the detected service and tracks the performance of the different IPs as separate service instances. In this way, you can set up detection to have:

  • A single service for multiple hosts and/or IP ranges.

  • Multiple services based on hostname subdomains.

  • Multiple services based on the superimposed context root.

Improve service detection

Web server naming issues

  • In some cases, web servers don't have well-defined virtual hosts, server names, or sites. A web server might simply be named localhost. This can result in multiple similar services that contain multiple website instances. To remedy such issues, adjust process-group detection settings.

  • When there is no virtual host configured on an Apache HTTP server, the web server name defaults to the name of the physical host. In cloud environments, this leads to one virtual host for each physical host instance and thus one service instance. If the cloud environment starts and stops the hosts, these services will be temporary.

    To remedy such localhost scenarios, use an environment variable to define virtual host names: set DT_LOCALTOVIRTUALHOSTNAME for each web server process to any value. Dynatrace will pick up the names and use them in place of the existing localhost virtual host names. With this approach, you ensure that multiple physical hosts report the same virtual host and thus get one service with multiple instances, one instance per physical host.

Define web application IDs

Some technologies don't provide unique application names. In such cases, you can define an environment variable called DT_APPLICATIONID to provide a unique name. This only impacts services of the respective process that don't already have application IDs. For Java applications, you can alternatively use the system property dynatrace.application.id.

Rotating and anonymous ports

Dynatrace takes the listen port of each web request service into account when naming and detecting requests. In some cases, these ports are meaningless or random, changing with each restart. This is especially true if you're using a load balancer that dynamically assigns ports to application processes, as is the case in many Node.js scenarios.

To remedy this, set environment variable DT_IGNOREDYNAMICPORT=true. This removes the port from detection and replaces it with *.

Frequently asked questions

When you create, edit, or delete a rule, data monitored after the change in service detection rules is aggregated and assigned to services, depending on the rule configuration. If a service stops receiving data, its historical data remains available (for example, for charting). You can still see the service and its traces in your environment.