feat: add prometheus metrics for TLS issuance and on-demand asks#7442
Open
pauloappbr wants to merge 2 commits intocaddyserver:masterfrom
Open
feat: add prometheus metrics for TLS issuance and on-demand asks#7442pauloappbr wants to merge 2 commits intocaddyserver:masterfrom
pauloappbr wants to merge 2 commits intocaddyserver:masterfrom
Conversation
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.
Closes #1683
Description
This PR introduces Prometheus metrics to the
caddytlsmodule to provide observability into certificate management and on-demand TLS operations. This addresses the long-standing request in #1683 and recent feedback from users needing visibility into rate limits and on-demand abuse.Changes
caddy_tls_obtain_total: Counter for certificates obtained or renewed (labeled byissuerandresult).caddy_tls_on_demand_ask_total: Counter for on-demand ASK requests (labeled byresultasallowed,denied, orerror).ctx.GetMetricsRegistry()withinProvision()instead ofinit(). This ensures integration with Caddy's internal metrics registry (admin endpoint) and supports graceful reloads by handlingAlreadyRegisteredError.Testing
Tested locally with a Caddyfile configured for
on_demand_tlswith an ask endpoint.Verification Steps:
on_demand_tlsenabled.curl -k https://<new-domain>.Output:
Assistance Disclosure
I consulted an AI assistant (Gemini) to help diagnose issues regarding the metrics registry context isolation and to refine the implementation pattern for graceful reloads. I authored the integration code, ran the builds, and verified the functionality myself.