Repository navigation
Externalize Prometheus Metrics into a Dedicated dnscrypt-proxy Exporter #3409
iampaarsaa
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
I would like to propose moving Prometheus metric exposition out of dnscrypt-proxy and providing it through a dedicated, standalone exporter.
dnscrypt-proxy already collects and maintains operational statistics and exposes them through its Monitoring UI and monitoring API. It also implements a native Prometheus endpoint.
However, I believe Prometheus exposition and metric transformation would be better handled by a separate application rather than being embedded in the dnscrypt-proxy codebase.
The proposed
dnscrypt-proxy-exporterwould consume the monitoring data already provided by dnscrypt-proxy, transform it into Prometheus-compatible metrics, and expose an independent/metricsendpoint.The intention is to externalize the Prometheus exporter itself, not to introduce another internal metrics implementation or duplicate existing functionality.
Motivation
I believe there are several advantages to separating metric exposition from the DNS proxy application.
1. Separation of concerns
dnscrypt-proxy's primary responsibility is DNS forwarding, resolver management, and related DNS functionality.
Prometheus metric exposition, on the other hand, is an observability and integration concern.
Keeping these responsibilities separate would help maintain a smaller and more focused core application. The proxy would remain responsible for collecting and making its operational state available, while the exporter would be responsible for translating that information into a monitoring-specific format.
This separation would also prevent the core application from accumulating additional dependencies, configuration options, and implementation complexity solely to accommodate different monitoring requirements.
2. Independent development and release lifecycle
An external exporter could be developed and released independently of dnscrypt-proxy.
This would allow:
Metric improvements without waiting for dnscrypt-proxy releases.
Independent development of new metric families and collectors.
Faster iteration on Prometheus conventions and metric compatibility.
Community contributions without requiring changes to the main application.
Compatibility handling across multiple dnscrypt-proxy versions.
Independent testing and maintenance of the observability integration.
Monitoring requirements often evolve independently of the DNS proxy's functionality. There is little reason for every change to metric exposition to require a change in the core application.
3. A richer and more flexible metric model
A standalone exporter could provide a more comprehensive Prometheus metric model than the existing implementation, without requiring the core application to implement and maintain every metric transformation.
For example, the exporter could:
Normalize metric names, units, and labels.
Expose additional operational information already available through the monitoring API.
Translate structured resolver-health information into Prometheus gauges.
Represent cache utilization and capacity as separate measurements.
Expose source-refresh status and timestamps.
Provide consistent exporter and collector health metrics.
Offer configurable metric families.
The goal is not to invent metrics or duplicate existing statistics. It is to make the available monitoring data more useful and accessible through a dedicated Prometheus integration.
4. Independent deployment and operational boundaries
A standalone exporter would have its own process, listen address, port, and lifecycle.
This provides several practical advantages:
Prometheus can scrape the exporter independently of the DNS listener.
The exporter can be updated or restarted without restarting dnscrypt-proxy.
The metrics endpoint can have its own network exposure and access policies.
Exporter resource consumption can be monitored and constrained independently.
Multiple dnscrypt-proxy instances can potentially be monitored through one exporter deployment.
Monitoring credentials and endpoint access can be managed separately from DNS traffic.
This is particularly useful in containerized environments and systems where DNS services and monitoring infrastructure have different operational requirements.
5. A reusable exporter ecosystem
A dedicated exporter could follow the same general approach as the Prometheus Unbound Exporter.
Rather than tying Prometheus-specific functionality to one application, the exporter would become an independently deployable integration that can be used with different Prometheus-compatible monitoring platforms.
It could also provide its own documentation, dashboards, alerting examples, and compatibility guarantees.
Proposed Architecture
The intended architecture would look like this:
There is only one Prometheus exposition endpoint in the proposed architecture: the one pro
vided by the standalone exporter.
The monitoring API is an internal data source for the exporter. It is not another Prometheus scrape endpoint and does not need to expose Prometheus-formatted metrics.
The responsibilities would be clearly separated:
dnscrypt-proxy
Collect DNS and resolver statistics.
Maintain its existing operational state.
Provide monitoring information through a stable application interface.
Avoid implementing Prometheus-specific exposition.
dnscrypt-proxy-exporter
Collect monitoring information from dnscrypt-proxy.
Transform the available data into Prometheus metrics.
Apply consistent metric naming, types, units, and labels.
Expose the Prometheus
/metricsendpoint.Provide exporter-specific health and collection metrics.
The existing monitoring API could be used as the initial data source. If some required operational information is not available through that API, the necessary data should be exposed through a stable machine-readable interface.
Existing Functionality and Migration Scope
The current Prometheus implementation already exposes several useful statistics, including query counts, QPS, cache hits and misses, cache hit ratio, blocked queries, average response time, per-server query counts, per-server average response time, query-type counts, and build information.
These capabilities should not be treated as new feature requests.
Instead, the standalone exporter should provide equivalent coverage, preserving existing metric semantics and avoiding loss of monitoring functionality during migration.
It should also make additional information available when that information is already present in the monitoring API but is not currently exposed through Prometheus.
Examples include:
Resolver health and status.
Resolver success ratios and scores.
Resolver observation age and timestamps.
Cache capacity and configured limits.
Cache TTL configuration.
Resolver-list source refresh status.
Source refresh timestamps and data age.
The exporter should not duplicate metrics that are already available through other dedicated community tools, particularly query-log analysis tools that independently derive query-level statistics and latency measurements.
Proposed Metric Coverage
The following metric families illustrate the additional monitoring information that could be exposed through the standalone exporter.
1. Resolver Health and Availability
dnscrypt_proxy_resolver_statusstatuslabel.dnscrypt_proxy_resolver_success_ratiodnscrypt_proxy_resolver_scorednscrypt_proxy_resolver_observation_age_secondsdnscrypt_proxy_resolver_last_update_timestamp_secondsdnscrypt_proxy_resolver_last_action_timestamp_secondsMigration and Compatibility
The external exporter should become the sole Prometheus-facing component, replacing the need for native Prometheus exposition inside dnscrypt-proxy.
A migration path should consider:
Providing equivalent coverage for the existing native Prometheus metrics.
Supporting the additional monitoring data currently available through the application API.
Documenting changes to metric names, types, and labels.
Providing a transition path for existing Prometheus configurations.
Deprecating and eventually removing the native Prometheus exposition and its related configuration from dnscrypt-proxy.
The application should not need to maintain two separate Prometheus implementations.
The existing monitoring API remains the data source, while the standalone exporter owns metric collection, transformation, and exposition.
Expected Benefits
Externalizing Prometheus metric exposition would provide:
A cleaner separation between DNS functionality and observability.
Less monitoring-specific code and configuration in dnscrypt-proxy.
Independent development and release cycles.
A richer and more flexible metric model.
Independent deployment, security, and resource boundaries.
Easier integration with Prometheus-compatible monitoring systems.
A reusable exporter that can evolve with community requirements.
Reduced maintenance burden on the core project.
Conclusion
I believe Prometheus metric exposition would be better implemented as a dedicated, standalone
dnscrypt-proxy-exporterrather than as functionality embedded in dnscrypt-proxy.dnscrypt-proxy should remain responsible for collecting and exposing its operational state through a stable application interface. The exporter should own the monitoring-specific responsibilities: collecting that information, transforming it into Prometheus metrics, and serving the single Prometheus scrape endpoint.
This would make the observability layer independently maintainable, easier to extend, and less coupled to the core DNS proxy implementation.
The objective is not to add another internal metrics endpoint or duplicate existing statistics. It is to externalize the existing Prometheus integration into a dedicated exporter and provide a better foundation for long-term observability.
All reactions