Set up Dynatrace with OpenTelemetry
Premium PartnerYou can use the OpenTelemetry plugin with Dynatrace SaaS to send analytics and monitoring data to Dynatrace dashboards. Set KONG_TRACING_INSTRUMENTATIONS=all
and KONG_TRACING_SAMPLING_RATE=1.0
. Enable the OTEL plugin with your Dynatrace tracing and log endpoint, specify the name you want to track the traces by in resource_attributes.service.name
, and add the Dynatrace API token as an Authorization header.
Prerequisites
Tracing environment variables
Set the following Dynatrace tracing variables before you configure the Data Plane:
export KONG_TRACING_INSTRUMENTATIONS=all
export KONG_TRACING_SAMPLING_RATE=1.0
Enable the OTEL plugin
In this tutorial, we’ll be configuring the OpenTelemetry plugin to send Kong Gateway traces and logs to Dynatrace SaaS. This configuration is good for testing purposes, but we recommend using a collector, like Dynatrace Collector, in production environments.
Enable the OTEL plugin with Dynatrace settings configured:
echo '
_format_version: "3.0"
plugins:
- name: opentelemetry
config:
traces_endpoint: https://${{ env "DECK_DYNATRACE_ENVIRONMENT_ID" }}.live.dynatrace.com/api/v2/otlp/v1/traces
logs_endpoint: https://${{ env "DECK_DYNATRACE_ENVIRONMENT_ID" }}.live.dynatrace.com/api/v2/otlp/v1/logs
resource_attributes:
service.name: kong-dev
headers:
Authorization: Api-Token ${{ env "DECK_DYNATRACE_API_TOKEN" }}
' | deck gateway apply -
Validate
Send a POST
request to generate traffic that we can use to validate that Dynatrace is receiving the traces:
curl -X POST "$KONNECT_PROXY_URL/anything" \
-H "Accept: application/json"\
-H "Content-Type: application/json"
curl -X POST "http://localhost:8000/anything" \
-H "Accept: application/json"\
-H "Content-Type: application/json"
In the Dynatrace UI, navigate to Distributed Traces and search for Service name
of kong-dev
. You should see a trace for the request you just sent. Sometimes it can take a few seconds to display.
Cleanup
Clean up Konnect environment
If you created a new control plane and want to conserve your free trial credits or avoid unnecessary charges, delete the new control plane used in this tutorial.