Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prometheus metrics #429

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Add prometheus metrics #429

wants to merge 9 commits into from

Conversation

mozzieongit
Copy link
Member

@mozzieongit mozzieongit commented Feb 11, 2025

This adds support for Prometheus metrics, exposed using libevent's HTTP server
implementation. It is feature gated with --enable-prometheus-metrics.

The statistics export and socket code is based on code from remote.c.

Here is an excerpt from the exported metrics:

nsd_queries_total{server="0"} 27
nsd_queries_total{server="1"} 22
nsd_queries_by_type_total{type="A"} 42
nsd_queries_by_class_total{class="IN"} 49
nsd_queries_by_opcode_total{opcode="QUERY"} 49
nsd_queries_by_rcode_total{rcode="NOERROR"} 48
nsd_queries_by_transport_total{transport="udp"} 25
nsd_queries_with_edns_total 49
nsd_queries_with_edns_failed_total 0

nsd_connections_total{transport="tcp"} 24
nsd_connections_total{transport="tls6"} 0

nsd_xfr_requests_served_total{xfrtype="AXFR"} 0
nsd_xfr_requests_served_total{xfrtype="IXFR"} 0

nsd_queries_dropped_total 0
nsd_queries_rx_failed_total 0

nsd_answers_tx_failed_total 0
nsd_answers_without_aa_total 0
nsd_answers_truncated_total 0

nsd_time_up_seconds_total 970.392208

nsd_size_db_on_disk_bytes 0
nsd_size_db_in_mem_bytes 0
nsd_size_xfrd_in_mem_bytes 1163464
nsd_size_config_on_disk_bytes 0
nsd_size_config_in_mem_bytes 2208

nsd_zones_primary 1
nsd_zones_secondary 0

nsd_zonestats_examplezone_queries_total 48
nsd_zonestats_examplezone_queries_by_type_total{type="A"} 41

@mozzieongit mozzieongit self-assigned this Feb 11, 2025
Metrics should not contain duplicate data, summing all metrics of
a given name (regardless of labels) needs to be meaningful. Therefore
the counter metrics based on different DNS aspects have been split into
separate metric names.
@mozzieongit
Copy link
Member Author

mozzieongit commented Feb 17, 2025

1. The elapsed time (`nsd_time_elapsed_seconds`) doesn't have much value
   currently, and doesn't reset when `nsd-control stats` is used, so I would
   probably remove it. However, it could be beneficial to reset this time
   whenever `nsd-control` resets the stats.

I disabled the elapsed time metric, until I point it to the remote-control time value.

2. For the zonestats block: Should the label name "zone" maybe renamed to
   "zonegroup" or something else?

I used zonestats, to copy the name from the config file.

3. Currently, the metrics don't have any HELP text (see [Prometheus Exposition Formats](https://prometheus.io/docs/instrumenting/exposition_formats/#comments-help-text-and-type-information))

Help and type annotations added.

@mozzieongit mozzieongit marked this pull request as ready for review February 17, 2025 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant