Skip to content

Commit

Permalink
re-add custom histogram buckets for #92
Browse files Browse the repository at this point in the history
  • Loading branch information
tykling committed Feb 28, 2024
1 parent e711da4 commit 95cdd13
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/dns_exporter/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Histogram,
Info,
)
from prometheus_client.utils import INF

from dns_exporter.version import __version__

Expand Down Expand Up @@ -227,6 +228,32 @@ def get_dns_failure_metric() -> CounterMetricFamily:
name="dnsexp_dns_responsetime_seconds",
documentation="DNS query response timing histogram. This histogram is updated every time the dns_exporter receives a query response.", # noqa: E501
labelnames=QTIME_LABELS,
buckets=(
1.0,
2.0,
4.0,
8.0,
16.0,
32.0,
64.0,
128.0,
256.0, # 4 minutes
512.0, # 8 minutes
1024.0, # 17 minutes
2048.0, # 34 minutes
4096.0, # 1 hour 8 minutes
8192.0, # 2 hours 16 minutes
16384.0, # 4.5 hours
32768.0, # 9.1 hours
65536.0, # 18.2 hours
131072.0, # 36.4 hours
262144.0, # 72.8 hours
524288.0, # 6 days
1048576.0, # 12 days
2097152.0, # 24 days
4194304.0, # 48 days
INF,
),
)
"""``dnsexp_dns_responsetime_seconds`` is the Histogram keeping track of how many DNS responses this exporter
received since start and how long the query took.
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def test_internal_metrics(dns_exporter_example_config, caplog):
dnsexp_http_responses_total{path="/query",response_code="200"} 75.0
dnsexp_http_responses_total{path="/",response_code="200"} 1.0
dnsexp_dns_queries_total 61.0
dnsexp_dns_responsetime_seconds_bucket{additional="0",answer="1",authority="0",family="ipv4",flags="QR RA RD",ip="8.8.4.4",le="0.005",nsid="no_nsid",opcode="QUERY",port="53",protocol="udp",proxy="none",query_name="example.com",query_type="A",rcode="NOERROR",server="udp://dns.google:53",transport="UDP"}
dnsexp_dns_responsetime_seconds_bucket{additional="0",answer="1",authority="0",family="ipv4",flags="QR RA RD",ip="8.8.4.4",le="2.0",nsid="no_nsid",opcode="QUERY",port="53",protocol="udp",proxy="none",query_name="example.com",query_type="A",rcode="NOERROR",server="udp://dns.google:53",transport="UDP"}
dnsexp_scrape_failures_total{reason="certificate_error"} 4.0
dnsexp_scrape_failures_total{reason="invalid_request_config"} 7.0
dnsexp_scrape_failures_total{reason="invalid_request_proxy"} 2.0
Expand Down

0 comments on commit 95cdd13

Please sign in to comment.