How to send metrics and logs to Datadog in a Kubernetes environment?
How to send metrics and logs to Datadog in a Kubernetes environment
How do I send Kong metrics and logs to Datadog in a Kubernetes environment?
Create a Datadog account and API key, then install the Datadog Agent via Helm. Enable the prometheus plugin in Kong so Datadog can scrape metrics via OpenMetrics, and add podAnnotations to the Kong Helm chart so Datadog’s Autodiscovery can collect metrics and logs from Kong pods.
Steps
The procedure is described in the Datadog documentation.
-
Create an account in Datadog in a Datadog site, notice that each Datadog site is independent.
export DD_SITE=datadoghq.eu -
Create an API key on your Datadog account.
export DD_API_KEY=123456789123456789123456789 -
Install the Datadog Agent via Helm chart.
helm install datadog \ --set datadog.site=$DD_SITE \ --set datadog.apiKey=$DD_API_KEY \ --set datadog.logs.enabled=true \ --set datadog.logs.containerCollectAll=true \ --set datadog.kubelet.tlsVerify=false \ datadog/datadog(
datadog.kubelet.tlsVerfiy = falseis required when running tests in minikube.) -
Datadog uses OpenMetrics to scrape metrics, we need to run the
prometheusplugin in Kong.apiVersion: configuration.konghq.com/v1 kind: KongClusterPlugin metadata: name: plugin-prometheus annotations: kubernetes.io/ingress.class: kong labels: global: "true" plugin: prometheuskubectl apply -f prometheus-plugin.yaml -
Add required
podAnnotationsin the Kong Helm chart to allow the Datadog agent to use Autodiscovery to collect metrics and logs from Kong pods:podAnnotations: ad.datadoghq.com/proxy.check_names: '["kong"]' ad.datadoghq.com/proxy.init_configs: '[{}]' ad.datadoghq.com/proxy.instances: '[{"openmetrics_endpoint": "http://%%host%%:8100/metrics"}]' ad.datadoghq.com/proxy.logs: '[{"source": "kong", "service": "kong-proxy"}]' ad.datadoghq.com/ingress-controller.logs: '[{"source": "kong", "service": "kong-ingress-controller"}]' -
Make sure that the status endpoint is enabled on your Helm chart.