In NSD 4.12.0, when you enable Prometheus metrics with metrics-enable: yes, and zonestats for say example.com and example.org with zonestats: "example_com" and "example_org" respectively, NSD will expose metrics in this format:
nsd_queries_by_type_total{type="A"} 198
nsd_queries_by_type_total{type="NS"} 198
...
nsd_zonestats_example_com_queries_by_type_total{type="A"} 99
nsd_zonestats_example_com_queries_by_type_total{type="NS"} 99
...
nsd_zonestats_example_org_queries_by_type_total{type="A"} 99
nsd_zonestats_example_org_queries_by_type_total{type="NS"} 99
...
The following format would be more useful:
nsd_zonestats_queries_by_type_total{type="A",zone="example.com"} 99
nsd_zonestats_queries_by_type_total{type="NS",zone="example.com"} 99
...
nsd_zonestats_queries_by_type_total{type="A",zone="example.org"} 99
nsd_zonestats_queries_by_type_total{type="NS",zone="example.org"} 99
...
In other words, put the zone in a label rather than in the metric name.
Advantages
- You can use any zone name, it doesn’t need to be a valid Prometheus identifier. In particular, it may contain a dot.
- It unlocks Prometheus features that work over metrics with labels but not over separate metrics:
- For example, we can select a subset of zones by regex, e.g.
nsd_zonestats_queries_by_type_total{zone =~ ".+\.nl"}.
- Functions like
sum, avg, etc. become available.
- It makes it easier to graph metrics.
- For example, you can query
rate(nsd_zonestats_queries_by_type_total{type="A"}[5m]) in the Prometheus webui, and it will graph the rates for all zones in a single graph.
- This also applies to Grafana, you can use the zone label as series name, and then with a single query Grafana will all zones in a single graph. It is possible to achieve the same result with differently named metrics, but it requires manually duplicating the query
n_zones times, and it requires manually updating the dashboard when zones are added or removed.
- Similar to graphing all zones at once, it is possible to create alerts for all zones at once, and use the
zone label in the alert description.
- It doesn’t pollute Prometheus with
O(n_zones) additional metrics. This matters for example in the Prometheus webui, or in graphing tools like Grafana, which autocomplete metric names, which is a valuable for exploring available metrics.
Impact
- For Prometheus storage it doesn’t matter, internally Prometheus stores every unique combination of labels as a separate metric so the number of timeseries doesn’t change.
- Queries change from
nsd_zonestats_example_com_queries_by_type_total to nsd_zonestats_queries_by_type_total{zone="example.com"} which is slightly longer, but on the positive side, the Prometheus webui has autocomplete for metrics, labels, and label values.
- This is a breaking change for people who rely on the current zonestats format.
@mozzieongit, I see you implemented Prometheus metrics originally in #429 (thanks for this feature!), what do you think?
In NSD 4.12.0, when you enable Prometheus metrics with
metrics-enable: yes, and zonestats for sayexample.comandexample.orgwithzonestats: "example_com"and"example_org"respectively, NSD will expose metrics in this format:The following format would be more useful:
In other words, put the zone in a label rather than in the metric name.
Advantages
nsd_zonestats_queries_by_type_total{zone =~ ".+\.nl"}.sum,avg, etc. become available.rate(nsd_zonestats_queries_by_type_total{type="A"}[5m])in the Prometheus webui, and it will graph the rates for all zones in a single graph.n_zonestimes, and it requires manually updating the dashboard when zones are added or removed.zonelabel in the alert description.O(n_zones)additional metrics. This matters for example in the Prometheus webui, or in graphing tools like Grafana, which autocomplete metric names, which is a valuable for exploring available metrics.Impact
nsd_zonestats_example_com_queries_by_type_totaltonsd_zonestats_queries_by_type_total{zone="example.com"}which is slightly longer, but on the positive side, the Prometheus webui has autocomplete for metrics, labels, and label values.@mozzieongit, I see you implemented Prometheus metrics originally in #429 (thanks for this feature!), what do you think?