Fix metrics implementation and add monitoring docs - #52
Merged
Conversation
externalcas/config.go:
- Fix Validate() writing to unused acmeProxyConfig.metricsEnabled field;
now correctly sets Metrics.Enabled so StartMetricsServer gates on it
- Remove the now-unused metricsEnabled bool field from acmeProxyConfig
externalcas/metrics.go:
- Remove certificatesRenewedTotal (renewal is indistinguishable from
first issuance at the CAS plugin layer)
- Remove acmeErrorsTotal (had no call sites)
- Remove comment block referencing client hostname/IP/ACME client
(not available at CAS layer)
- Replace promauto.New* with prometheus.New* to eliminate silent
double-registration against the default global registry
- Isolate all metrics to a dedicated registry; register Go runtime
(go_goroutines, GC, heap) and process (RSS, CPU, FDs) collectors
into it so they appear on /metrics
- Add runCAHealthProbe: probes caURL immediately on startup then every
30s, sets externalcas_external_ca_up to 1 (2xx) or 0 (error/non-2xx)
- StartMetricsServer now accepts caURL string to pass to the probe
externalcas/external.go:
- Observe certificateRequestDuration and acmeRoundtripDuration histograms
on both success and failure paths of CreateCertificate and
RevokeCertificate (were defined but never called)
- Observe certificateExpirationTime (cert lifetime in seconds) on
successful issuance
- Call lastSuccessfulCertificateTimestamp.SetToCurrentTime() on
successful issuance (was always 0)
- Wrap ACME account registration calls to observe
acmeRoundtripDuration{acme_operation="register"}
- Pass cfg.CaURL into StartMetricsServer
contrib/develop/monitoring.md:
- Document setup of Prometheus and Grafana on acme-proxy-testbridge
- Full metrics reference split into three sections: per-certificate
custom collector, aggregate in-process metrics, Go runtime/process
- PromQL organized by Grafana panel type across five dashboard rows
- Alert rule expressions for CA down, cert expiry, failure rate, and
no recent issuance
- Notes on renewal detection via PromQL (count by CN/SAN - 1)
contrib/develop/prometheus.yml:
- Scrape config targeting acme-proxy.duckdns.org:9234
contrib/develop/grafana-dashboard.json:
- Importable Grafana dashboard with datasource template variable
- Five rows: health overview (Stat), operations (time series),
latency P50/P95/P99, certificate inventory (Table with
color-coded days remaining), Go runtime panels
Signed-off-by: Kapil Agrawal <7047165+netops2devops@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #52 +/- ##
==========================================
- Coverage 47.08% 44.17% -2.92%
==========================================
Files 6 6
Lines 446 489 +43
==========================================
+ Hits 210 216 +6
- Misses 225 262 +37
Partials 11 11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix config validation bug where Validate() wrote to an unused field, causing metrics to silently not start even when port and dataSource were configured
Remove dead metrics (certificatesRenewedTotal, acmeErrorsTotal) and fix double-registration against the default Prometheus registry by replacing promauto with explicit registry-scoped registration
Wire all previously defined-but-never-observed histograms (certificateRequestDuration, acmeRoundtripDuration, certificateExpirationTime) and lastSuccessfulCertificateTimestamp gauge at their correct call sites in CreateCertificate and RevokeCertificate
Add a background health probe for the external CA directory URL that sets externalcas_external_ca_up to 1 or 0 every 30 seconds (was permanently 0)
Register Go runtime and process collectors into the isolated registry so goroutines, GC, heap, CPU, and FD metrics appear on /metrics
Add contrib/develop/monitoring.md documenting the full metrics reference, Prometheus/Grafana setup on the test bridge network, PromQL organized by panel type, alert rules, and renewal detection approach
Add contrib/develop/grafana-dashboard.json, an importable Grafana 13 dashboard with five rows covering health overview, operation rates, latency percentiles, certificate inventory with expiry coloring, and Go runtime panels