Get metrics from CoreDNS in real time to visualize and monitor DNS failures and cache hits/misses.
The CoreDNS check is included in the Datadog Agent package, so you don't need to install anything else on your servers.
Note: The current version of the check (1.11.0+) uses OpenMetrics (OpenMetricsBaseCheckV2) for metric collection, which requires Python 3. For hosts unable to use Python 3, or to use the legacy OpenMetricsBaseCheckV1 version of this check, see the following config. There is an exception to that for Autodiscovery users relying on the coredns.d/auto_conf.yaml
file, which enables the prometheus_url
option for the OpenMetricsBaseCheckV1 legacy version of the check by default. See the sample coredns.d/auto_conf.yaml for the default configuration options and the sample coredns.d/conf.yaml.example for all available configuration options.
Note: The OpenMetricsBaseCheckV2 version of the CoreDNS check now submits .bucket
metrics and submits the .sum
and .count
histogram samples as monotonic count type. These metrics were previously submitted as gauge type in OpenMetricsBaseCheckV1. See the metadata.csv for the list of metrics available in each version.
To configure this check for an Agent running on a container:
Set Autodiscovery Integration Templates as Docker labels on your application container:
LABEL "com.datadoghq.ad.check_names"='["coredns"]'
LABEL "com.datadoghq.ad.init_configs"='[{}]'
LABEL "com.datadoghq.ad.instances"='[{"openmetrics_endpoint":"http://%%host%%:9153/metrics", "tags":["dns-pod:%%host%%"]}]'
To enable the legacy OpenMetricsBaseCheckV1 version of the check, replace openmetrics_endpoint
with prometheus_url
:
LABEL "com.datadoghq.ad.instances"='[{"prometheus_url":"http://%%host%%:9153/metrics", "tags":["dns-pod:%%host%%"]}]'
Notes:
- The shipped
coredns.d/auto_conf.yaml
file enables the legacy OpenMetricsBaseCheckV1 option,prometheus_url
, by default. - The
dns-pod
tag keeps track of the target DNS pod IP. The other tags are related to the dd-agent that is polling the information using the service discovery. - The service discovery annotations need to be done on the pod. In case of a deployment, add the annotations to the metadata of the template's specifications. Do not add it at the outer specification level.
Collecting logs is disabled by default in the Datadog Agent. To enable it, see Docker Log Collection.
Then, set Log Integrations as Docker labels:
LABEL "com.datadoghq.ad.logs"='[{"source":"coredns","service":"<SERVICE_NAME>"}]'
To configure this check for an Agent running on Kubernetes:
Set Autodiscovery Integrations Templates as pod annotations on your application container. Alternatively, you can configure templates with a file, configmap, or key-value store.
apiVersion: v1
kind: Pod
metadata:
name: coredns
annotations:
ad.datadoghq.com/coredns.check_names: '["coredns"]'
ad.datadoghq.com/coredns.init_configs: '[{}]'
ad.datadoghq.com/coredns.instances: |
[
{
"openmetrics_endpoint": "http://%%host%%:9153/metrics",
"tags": ["dns-pod:%%host%%"]
}
]
labels:
name: coredns
spec:
containers:
- name: coredns
To enable the legacy OpenMetricsBaseCheckV1 version of the check, replace openmetrics_endpoint
with prometheus_url
:
ad.datadoghq.com/coredns.instances: |
[
{
"prometheus_url": "http://%%host%%:9153/metrics",
"tags": ["dns-pod:%%host%%"]
}
]
Notes:
- The shipped
coredns.d/auto_conf.yaml
file enables the legacy OpenMetricsBaseCheckV1 option,prometheus_url
, by default. - The
dns-pod
tag keeps track of the target DNS pod IP. The other tags are related to the Datadog Agent that is polling the information using the service discovery. - The service discovery annotations need to be done on the pod. In case of a deployment, add the annotations to the metadata of the template's specifications. Do not add it at the outer specification level.
Collecting logs is disabled by default in the Datadog Agent. To enable it, see Kubernetes Log Collection.
Then, set Log Integrations as pod annotations. Alternatively, you can configure this with a file, configmap, or key-value store.
apiVersion: v1
kind: Pod
metadata:
name: coredns
annotations:
ad.datadoghq.com/coredns.logs: '[{"source": "coredns", "service": "<SERVICE_NAME>"}]'
labels:
name: coredns
To configure this check for an Agent running on ECS:
Set Autodiscovery Integrations Templates as Docker labels on your application container:
{
"containerDefinitions": [{
"name": "coredns",
"image": "coredns:latest",
"dockerLabels": {
"com.datadoghq.ad.check_names": "[\"coredns\"]",
"com.datadoghq.ad.init_configs": "[{}]",
"com.datadoghq.ad.instances": "[{\"openmetrics_endpoint\":\"http://%%host%%:9153/metrics\", \"tags\":[\"dns-pod:%%host%%\"]}]"
}
}]
}
To enable the legacy OpenMetricsBaseCheckV1 version of the check, replace openmetrics_endpoint
with prometheus_url
:
"com.datadoghq.ad.instances": "[{\"prometheus_url\":\"http://%%host%%:9153/metrics\", \"tags\":[\"dns-pod:%%host%%\"]}]"
Notes:
- The shipped
coredns.d/auto_conf.yaml
file enables the legacy OpenMetricsBaseCheckV1 option,prometheus_url
, by default. - The
dns-pod
tag keeps track of the target DNS pod IP. The other tags are related to the Datadog Agent that is polling the information using the service discovery. - The service discovery annotations need to be done on the pod. In case of a deployment, add the annotations to the metadata of the template's specifications. Do not add it at the outer specification level.
Collecting logs is disabled by default in the Datadog Agent. To enable it, see ECS Log Collection.
Then, set Log Integrations as Docker labels:
{
"containerDefinitions": [{
"name": "coredns",
"image": "coredns:latest",
"dockerLabels": {
"com.datadoghq.ad.logs": "[{\"source\":\"coredns\",\"service\":\"<SERVICE_NAME>\"}]"
}
}]
}
Run the Agent's status
subcommand and look for coredns
under the Checks section.
See metadata.csv for a list of metrics provided by this integration.
The CoreDNS check does not include any events.
See service_checks.json for a list of service checks provided by this integration.
Need help? Contact Datadog support.