Expose angie ACME state and reuse cert expiry#13
Merged
Conversation
- New angie ACMECollector polls /status/http/acme_clients/?date=epoch
and emits topsrv_angie_acme_state{name,state,certificate} plus
topsrv_angie_acme_next_run_seconds, so dashboards can alert on
certificate!=valid, state=error, or stuck renewal. 404-silent on
hosts without acme_client configured
- Extend nginx.DiscoverConfig to parse acme_client directives and
pick up <state_path>/<name>/certificate.pem from angie's default
/var/lib/angie/acme location; the file lands in the existing
topsrv_ssl_certificate_expiry_seconds metric so ACME-cert expiry
reuses the same series as static certs — no new metric, no
dashboard split
- Skip commented `# acme_client` lines and reject names with path
separators or `..` components — defense in depth around the
filepath.Join into defaultACMEStatePath
- Guard NewACMECollector URL derivation against a misconfigured
statusURL that already points at the ACME endpoint (no double
/http/acme_clients/ suffix)
- Surface "angie: ACME certs missing at default state path" at
startup when the config has more acme_client directives than
certs on disk — operators on custom acme_client_path builds get
a hint instead of silent expiry gaps
- Extract PromQL recipe blocks from docs/metrics.md into a new
docs/promql-recipes.md so the metric reference stays a reference
- 10 tests: collector (happy path with angie 1.x response shape,
404-silent, next_run omission, URL derivation incl double-suffix
guard, malformed URL) and discovery (real-layout pickup, missing
file skip, dedup, commented-line skip, traversal-name reject)
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.
Summary
Adds visibility into angie's built-in ACME client (1.5+) without inventing a separate expiry metric — the existing
topsrv_ssl_certificate_expiry_secondsseries picks up ACME-managed PEMs the same way it picks up static ones.New:
angie.ACMECollector/status/http/acme_clients/?date=epochon every scrape — same angie process asAPICollector, derived fromStatusURL.topsrv_angie_acme_state{name, state, certificate}—value=1per active acme_client tuple.state∈ {ready, requesting, disabled, failed};certificate∈ {valid, expired, missing, mismatch, error}.topsrv_angie_acme_next_run_seconds{name}— Unix timestamp of next scheduled action (omitted when state=disabled/requesting).acme_clientconfigured — no log spam.StatusURLthat already points at the ACME endpoint (no double/http/acme_clients/).Reuse: ACME PEM auto-discovery in
nginx.DiscoverConfigacme_client <name>directives fromangie.conf(line-by-line, skips# acme_clientcomments).<defaultACMEStatePath>/<name>/certificate.pemtoSSLCertificatesfor the existingnginx.SSLCollector— ACME-cert expiry flows throughtopsrv_ssl_certificate_expiry_secondsautomatically. No new expiry metric, no dashboard split./,\, or..(path-traversal intofilepath.Join)."angie: ACME certs missing at default state path"when the config has moreacme_clientdirectives than certs found on disk — hints at a customacme_client_pathbuild option we don't auto-discover.Docs reshuffle
docs/metrics.mdkeeps the metric reference clean (no inline PromQL anymore).docs/promql-recipes.mdholds the recipe blocks (Netstat listening ports, Netstat connection scope, Angie ACME).Verification
{state, certificate, details, next_run}map keyed by client name;date=epochreturns plain Unix int./var/lib/angie/acme/<client_name>/certificate.pem(plusprivate.key,account.key)./api/http/acme_clients/to the documented/status/http/acme_clients/.Test plan
make fmt lint test— 0 lint issues, all unit tests greenmake test-integration— full docker-compose stack passesTestIntegrationACMECollectorSurvivesNoACME— against realangie:minimalin docker-compose: 404 path is silent, no series emitted, no panictopsrv_angie_acme_stateshows up withstate="ready", certificate="valid"and thattopsrv_ssl_certificate_expiry_secondscarries the ACMEcertificate.pempathsOut of scope / follow-ups
acme_client_pathparsing — operators on non-default builds get a warning log instead of silent expiry coverage. Adding directive parsing is a small follow-up if it shows up in practice.