To enable Kong Observability in Dynatrace, you have the following options.
recommended Enable OneAgent for Gateway logs, traces, and process monitoring. This should be combined with Dynatrace Prometheus scraping to monitor Kong Gateway metrics.
Monitor Kong using a combination of OpenTelemetry for traces and Prometheus for Kong Gateway metrics.
Kong Gateway process and logs
OneAgent automatically monitors the Kong Gateway process and logs.
Prerequisites
Kong Gateway version 2.8+
OneAgent or Dynatrace Operator is installed and available for monitoring your Kong Gateway.
The required installation depends on your application:
Evaluate support for logging and tracing according to the OpenTelemetry plugin version installed in your environment.
Send the following POST request (example assumes Kong Gateway 3.8+) by replacing {HOST}, {PLUGIN-INSTANCE_NAME} and {OPENTELEMETRY_COLLECTOR} with proper values:
Configure your OpenTelemetry Collector to send data to your Dynatrace environment. The example below shows how to export traces and logs.
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
exporters:
otlphttp:
endpoint:"${env:DT_BASEURL}/api/v2/otlp"
headers:
"Authorization":"Api-Token ${env:DT_API_TOKEN}"
service:
pipelines:
traces:
receivers:[otlp]
processors:[]
exporters:[otlphttp]
logs:
receivers:[otlp]
processors:[]
exporters:[otlphttp]
Export Application Span Metrics
To include span metrics for application traces, configure the collector exporters section of the OpenTelemetry Collector configuration.
connectors:
spanmetrics:
dimensions:
-name: http.method
default: GET
-name: http.status_code
-name: http.route
exclude_dimensions:
- status.code
metrics_flush_interval: 15s
histogram:
disable:false
service:
pipelines:
traces:
receivers:[otlp]
processors:[]
exporters:[spanmetrics]
metrics:
receivers:[spanmetrics]
processors:[]
exporters:[otlphttp]
Metrics
Kong’s Prometheus plugin is a convenient way to collect Kong Gateway metrics. Dynatrace can collect these metrics directly from the Gateway produced by the Kong plugin. The default port and endpoint is 8001/metrics.
To enable basic configuration of the Kong Prometheus plugin send a POST request replacing {HOST} with the host name value.
curl -s -X POST http://{HOST}:8001/plugins \
-H 'Content-Type: application/json'\
-d '{
"name": "prometheus"
}'
Additional plugin metrics
To enable additional metrics produced by the Kong Gateway Prometheus plugin, send a POST request replacing {HOST} and {PLUGIN-INSTANCE_NAME} with proper values:
curl -s -X POST http://{HOST}:8001/plugins \
-H 'Content-Type: application/json'\
-d '{
"name": "prometheus",
"instance_name": "{PLUGIN-INSTANCE_NAME}",
"config": {
"per_consumer": true,
"status_code_metrics": true,
"latency_metrics": true,
"bandwidth_metrics": true,
"upstream_health_metrics": true
}
}'
To check available Kong metrics, query the /metrics endpoint:
curl -i http://{HOST}:8001/metrics
Collect Prometheus metrics
After configuring Kong Gateway's Prometheus plugin, metrics can be collected using the Dynatrace ActiveGate (recommended) or the OpenTelemetry Collector.
Scrape metrics using ActiveGate
In Kubernetes, Dynatrace supports scraping of Prometheus endpoints using special annotations.
You can also use the OpenTelemetry Collector’s Prometheus receiver to collect metrics from the Kong Gateway. To learn how to scrape Prometheus data using an OpenTelemetry collector, see Scrape data from Prometheus.
If you're running on Kubernetes, you can enrich traces, metrics, and logs using the Collector's Kubernetes attribute processor. This allows Dynatrace to map the telemetry data to the correct toplogy. To learn how to enable enrichment in the OpenTelemetry Collector, see Enrich from Kubernetes.