The following configuration example shows how to configure a Collector instance to transform and manipulate OTLP requests, before forwarding them to Dynatrace.
Using the processors shown in this example (filter and transform), it is possible to streamline requests before sending them to Dynatrace and omit data possibly irrelevant to your use case, and to reduce billing costs.
See Collector Deployment and Collector Configuration on how to set up your Collector with the configuration below.
receivers:otlp:protocols:grpc:endpoint: 0.0.0.0:4317http:endpoint: 0.0.0.0:4318processors:transform:trace_statements:- context: resourcestatements:# Only keep a certain set of resource attributes- keep_matching_keys(attributes, "^(aaa|bbb|ccc).*")- context: spanstatements:# Only keep a certain set of span attributes- keep_matching_keys(attributes, "(^xyz.pqr$)|(^(aaa|bbb|ccc).*)")# Set a static key- set(attributes["svc.marker"], "purchasing")# Delete a specific key- delete_key(attributes, "message")# Rewrite a key- set(attributes["purchase.id"], ConvertCase(attributes["purchase.id"], "upper"))# Apply regex replacement- replace_pattern(name, "^.*(DataSubmission-\d+).*$", "$$1")metric_statements:- context: metricstatements:# Rename all metrics containing '_bad' suffix in their name with `_invalid`- replace_pattern(name, "(.*)_bad$", "$${1}_invalid")filter:error_mode: ignoretraces:span:# Filter spans with resource attributes matching the provided regular expression- IsMatch(resource.attributes["k8s.pod.name"], "^my-pod-name.*")metrics:metric:# Filter metrics which contain at least one data point with a "bad.metric" attribute- 'HasAttrKeyOnDatapoint("bad.metric")'logs:log_record:# Filter logs with resource attributes matching the configured names- resource.attributes["service.name"] == "service1"- resource.attributes["service.name"] == "service2"exporters:otlp_http:endpoint: ${env:DT_ENDPOINT}headers:Authorization: "Api-Token ${env:DT_API_TOKEN}"service:pipelines:traces:receivers: [otlp]processors: [filter,transform]exporters: [otlp_http]metrics:receivers: [otlp]processors: [filter]exporters: [otlp_http]logs:receivers: [otlp]processors: [filter]exporters: [otlp_http]
Validate your settings to avoid any configuration issues.
For our configuration, we configure the following components.
Under receivers, we specify the standard otlp receiver as active receiver component for our Collector instance.
This is for demonstration purposes. You can specify any other valid receiver here (for example, zipkin).
Under processors, we specify the transform processor with a set of different attribute modification statements. context indicates the scope to which the statements should apply (here, resource for resource attributes, span for span attributes, and metric for metrics).
See the OpenTelemetry documentation of the transform processor for more details on the individual configuration options.
The sample configuration above uses the following statements:
In addition, we also configure an instance of the filter processor, to filter signal based on the following criteria:
See the OpenTelemetry documentation of the filter processor for more details on the individual configuration options.
Under exporters, we specify the default otlp_http exporter and configure it with our Dynatrace API URL and the required authentication token.
For this purpose, we set the following two environment variables and reference them in the configuration values for endpoint and Authorization.
DT_ENDPOINT contains the base URL of the Dynatrace API endpoint (for example, https://{your-environment-id}.live.dynatrace.com/api/v2/otlp)DT_API_TOKEN contains the API tokenUnder service, we assemble our receiver, processor, and exporter objects into a traces pipeline, which accepts OTLP traces on the configured endpoints and transforms trace attributes according to the configured rules, before forwarding everything to Dynatrace using the exporter.
Data is ingested using the OpenTelemetry protocol (OTLP) via the Dynatrace OTLP APIs and is subject to the API's limits and restrictions. For more information see: