Skip to content

Commit ae365a8

Browse files
committed
If no metrics are set, use a default set
1 parent 4db107e commit ae365a8

File tree

3 files changed

+52
-7
lines changed

3 files changed

+52
-7
lines changed

coredns/datadog_checks/coredns/coredns.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
from datadog_checks.checks.openmetrics import OpenMetricsBaseCheck
66
from datadog_checks.errors import CheckException
77

8+
9+
DEFAULT_METRICS = {
10+
'coredns_dns_response_size_bytes': 'response_size.bytes',
11+
'coredns_cache_hits_total': 'cache_hits_count',
12+
'coredns_cache_misses_total': 'cache_misses_count',
13+
'coredns_dns_request_count_total': 'request_count',
14+
'coredns_dns_request_duration_seconds': 'request_duration.seconds',
15+
'coredns_dns_request_size_bytes': 'request_size.bytes',
16+
'coredns_dns_request_type_count_total': 'request_type_count',
17+
'coredns_dns_response_rcode_count_total': 'response_code_count',
18+
'coredns_proxy_request_count_total': 'proxy_request_count',
19+
'coredns_proxy_request_duration_seconds': 'proxy_request_duration.seconds',
20+
'coredns_cache_size': 'cache_size.count',
21+
}
22+
23+
824
GO_METRICS = {
925
'go_gc_duration_seconds': 'go.gc_duration_seconds',
1026
'go_goroutines': 'go.goroutines',
@@ -94,7 +110,12 @@ def _create_core_dns_instance(self, instance):
94110
else:
95111
send_monotonic = True
96112

97-
metrics = instance.get('metrics', []) + [GO_METRICS]
113+
metrics = instance.get('metrics', [])
114+
if metrics is None:
115+
metrics = metrics + [GO_METRICS]
116+
else:
117+
metrics = [DEFAULT_METRICS, GO_METRICS]
118+
98119
instance.update({
99120
'namespace': 'coredns',
100121
'prometheus_url': endpoint,

coredns/datadog_checks/coredns/data/auto_conf.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ instances:
1717
send_monotonic_counter: True
1818

1919
metrics:
20-
# Metrics are being emitted from the below plugins
20+
# metrics are being emitted from the below plugins
21+
# to map metrics from other plugins use the format below
2122
# https://coredns.io/plugins/metrics/
2223
# https://coredns.io/plugins/proxy/
2324
# https://coredns.io/plugins/cache/

coredns/datadog_checks/coredns/data/conf.yaml.example

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,32 @@ init_config:
22
# Leave empty
33

44
instances:
5-
# url of the metrics endpoint of prometheus
6-
- prometheus_url: http://localhost:9153/metrics
7-
# The histogram buckets can be noisy and generate a lot of tags.
8-
# send_histograms_buckets controls whether or not you want to pull them.
9-
#
5+
# To enable CoreDNS metrics you must specify the prometheus url and enable the plugin within coredns
6+
# See: https://coredns.io/plugins/metrics/
7+
- prometheus_url: "http://%%host%%:9153/metrics"
8+
tags:
9+
- "dns-pod:%%host%%"
10+
11+
# To send the histograms bucket
1012
# send_histograms_buckets: True
13+
14+
# To send counters as monotonic counter
15+
# send_monotonic_counter: True
16+
17+
metrics:
18+
# metrics are being emitted from the below plugins
19+
# to map metrics from other plugins use the format below
20+
# https://coredns.io/plugins/metrics/
21+
# https://coredns.io/plugins/proxy/
22+
# https://coredns.io/plugins/cache/
23+
- coredns_dns_response_size_bytes: response_size.bytes
24+
- coredns_cache_hits_total: cache_hits_count
25+
- coredns_cache_misses_total: cache_misses_count
26+
- coredns_dns_request_count_total: request_count
27+
- coredns_dns_request_duration_seconds: request_duration.seconds
28+
- coredns_dns_request_size_bytes: request_size.bytes
29+
- coredns_dns_request_type_count_total: request_type_count
30+
- coredns_dns_response_rcode_count_total: response_code_count
31+
- coredns_proxy_request_count_total: proxy_request_count
32+
- coredns_proxy_request_duration_seconds: proxy_request_duration.seconds
33+
- coredns_cache_size: cache_size.count

0 commit comments

Comments
 (0)