Observability - OpenIDC/mod_auth_openidc GitHub Wiki
Since version 2.4.15 mod_auth_openidc allows for collection and retrieval of a number of metrics that are designed to be used in systems monitoring and alerting tools such as Prometheus. Version 2.4.15.1 reworked that implementation and fixed an overlap in the Prometheus output, so 2.4.15.1 is the recommended minimum.
The OIDCMetricsData primitive configures the top level classes of metrics that will be collected.
The second column of each listing below is the version of mod_auth_openidc in which that class, timer or counter was introduced.
authtype 2.4.15 Request counter, overall and per AuthType: openid-connect, oauth20 and auth-openidc.
authn 2.4.15 Authentication request creation and response processing.
authz 2.4.15 Authorization errors per OIDCUnAutzAction (per Require statement, not overall).
require.claim 2.4.15 Match/failure count of Require claim directives (per Require statement, not overall).
claim 2.4.16.8 Claims per value.
provider 2.4.15 Requests to the provider [token, userinfo, metadata] endpoints.
session 2.4.15 Existing session processing.
cache 2.4.15 Cache read/write timings and errors.
logout 2.4.20.1 Front- and back-channel logout processing.
redirect_uri 2.4.15 Requests to the Redirect URI, per type.
content 2.4.15 Requests to the content handler, per type of request: info, metrics, jwks, etc.
Metrics are recorded and published per defined virtual host in Apache. Two types of metrics exists:
- timers: recorded as a histogram: count, sum and 13 buckets (0.1, 0.5, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000 and 30000 ms, plus
+Inf); the 10000 and 30000 ms buckets were added in 2.4.20.4 - counters: recorded as a cumulative total
authtype.handler 2.4.15 Histogram of the overall authn+authz processing time.
authn.request 2.4.15 Histogram of authentication requests.
authn.response 2.4.15 Histogram of authentication responses.
session.valid 2.4.15 Histogram of successfully validated existing sessions.
provider.metadata 2.4.15 Histogram of provider discovery document requests.
provider.token 2.4.15 Histogram of provider token requests.
provider.refresh 2.4.15 Histogram of provider refresh token requests.
provider.userinfo 2.4.15 Histogram of provider userinfo requests.
provider.jwks 2.4.20.1 Histogram of provider JWKs document requests.
provider.par 2.4.20.1 Histogram of provider pushed authorization requests.
cache.read 2.4.15 Histogram of cache read requests.
cache.write 2.4.15 Histogram of cache write requests.
authtype.mod_auth_openidc 2.4.15 Nr of requests handled by mod_auth_openidc.
authtype.openid-connect 2.4.15 Nr of requests handled by AuthType openid-connect.
authtype.oauth20 2.4.15 Nr of requests handled by AuthType oauth20.
authtype.auth-openidc 2.4.15 Nr of requests handled by AuthType auth-openidc.
authtype.declined 2.4.15 Nr of requests not handled by mod_auth_openidc.
authn.request.error.url 2.4.15 Nr of errors matching the incoming request URL against the configuration.
authn.response.error.state-mismatch 2.4.15 Nr of state mismatch errors in authentication responses.
authn.response.error.state-expired 2.4.15 Nr of state expired errors in authentication responses.
authn.response.error.provider 2.4.15 Nr of errors returned by the provider in authentication responses.
authn.response.error.protocol.<reason> 2.4.15 Nr of protocol errors handling authentication responses.
authn.response.error.remote-user 2.4.15 Nr of errors identifying the remote user based on provided claims.
authz.action.auth 2.4.15 Nr of step-up authentication requests.
authz.action.401 2.4.15 Nr of 401 authorization errors.
authz.action.403 2.4.15 Nr of 403 authorization errors.
authz.action.302 2.4.15 Nr of 302 authorization errors.
authz.error.oauth20.<reason> 2.4.15 Nr of AuthType oauth20 (401) authorization errors.
require.claim.match.<claim-value> 2.4.15 Nr of (per-) Require claim authorization matches.
require.claim.error.<claim-value> 2.4.15 Nr of (per-) Require claim authorization errors.
claim.id_token.<claim-name> 2.4.16.8 Nr of claim values in the ID Token.
claim.userinfo.<claim-name> 2.4.16.8 Nr of claim values returned from the Userinfo Endpoint.
provider.metadata.error 2.4.15 Nr of errors retrieving a provider discovery document.
provider.token.error 2.4.15 Nr of errors making a token request to a provider.
provider.refresh.error 2.4.15 Nr of errors refreshing the access token at the token endpoint.
provider.userinfo.error 2.4.15 Nr of errors calling a provider userinfo endpoint.
provider.http.connect.error.<string> 2.4.15 Nr of (libcurl) provider/network connectivity errors.
provider.http.response.code.<code> 2.4.15 Nr of HTTP response code calling a provider endpoint.
provider.jwks.error 2.4.20.1 Nr of errors retrieving a provider JWKs document.
provider.par.error 2.4.20.1 Nr of errors making a pushed authorization request to a provider.
provider.registration.error 2.4.20.1 Nr of errors registering a client dynamically at a provider.
provider.revocation.error 2.4.20.1 Nr of errors revoking a token at a provider revocation endpoint.
provider.dpop.retry 2.4.20.1 Nr of provider calls retried with a fresh DPoP nonce.
session.error.cookie-domain 2.4.15 Nr of cookie domain validation errors for existing sessions.
session.error.expired 2.4.15 Nr of sessions that exceeded the maximum duration.
session.error.refresh-access-token 2.4.15 Nr of errors refreshing the access token before expiry in existing sessions.
session.error.refresh-user-info 2.4.15 Nr of errors refreshing claims from the userinfo endpoint in existing sessions.
session.error.general 2.4.15 Nr of existing sessions that failed validation.
session.fallback-cookie 2.4.20.1 Nr of sessions stored in a browser cookie after a session cache write failure.
cache.cache.error.<backend> 2.4.15 Nr of cache read/write errors, per cache backend.
cache.cache.retry 2.4.20.1 Nr of cache operations retried after a backend failure.
cache.cache.hit 2.4.20.4 Nr of cache reads that found the requested key.
cache.cache.miss 2.4.20.4 Nr of cache reads that did not find the requested key.
cache.cache.eviction 2.4.20.4 Nr of live entries evicted from the shm cache before expiry to make room.
logout.backchannel 2.4.20.1 Nr of back-channel logout requests processed successfully.
logout.backchannel.error 2.4.20.1 Nr of back-channel logout requests rejected.
redirect_uri.authn.response.redirect 2.4.15 Nr of authentication responses received in a redirect.
redirect_uri.authn.response.post 2.4.15 Nr of authentication responses received in a HTTP POST.
redirect_uri.authn.response.implicit 2.4.15 Nr of (presumed) implicit authentication responses to the redirect URI.
redirect_uri.discovery.response 2.4.15 Nr of discovery responses to the redirect URI.
redirect_uri.request.logout 2.4.15 Nr of logout requests to the redirect URI.
redirect_uri.request.jwks 2.4.15 Nr of JWKs retrieval requests to the redirect URI.
redirect_uri.request.session 2.4.15 Nr of session management requests to the redirect URI.
redirect_uri.request.refresh 2.4.15 Nr of refresh access token requests to the redirect URI.
redirect_uri.request.request_uri 2.4.15 Nr of Request URI calls to the redirect URI.
redirect_uri.request.remove_at_cache 2.4.15 Nr of access token cache removal requests to the redirect URI.
redirect_uri.request.revoke_session 2.4.15 Nr of revoke session requests to the redirect URI.
redirect_uri.request.info 2.4.15 Nr of info hook requests to the redirect URI.
redirect_uri.request.dpop 2.4.16 Nr of DPoP proof requests to the redirect URI.
redirect_uri.error.provider 2.4.15 Nr of provider authentication response errors received at the redirect URI.
redirect_uri.error.invalid 2.4.15 Nr of invalid requests to the redirect URI.
content.request.declined 2.4.15 Nr of requests declined by the content handler.
content.request.info 2.4.15 Nr of info hook requests to the content handler.
content.request.dpop 2.4.16 Nr of DPoP proof requests to the content handler.
content.request.jwks 2.4.15 Nr of JWKs requests to the content handler.
content.request.discovery 2.4.15 Nr of discovery requests to the content handler.
content.request.post-preserve 2.4.15 Nr of HTTP POST preservation requests to the content handler.
content.request.authn-post 2.4.16.11 Nr of HTTP POST authentication requests to the content handler.
content.request.unknown 2.4.15 Nr of unknown requests to the content handler.
A counter that is listed with a .<...> suffix is recorded per value. Three of those values were added to a counter that existed before:
-
<reason>inauthn.response.error.protocol(2.4.20.4) is the check that the ID token failed:parse,signature,iss,exp,iat,nonce,sub,aud,at_hashorc_hash; an error for which no specific check was recorded is counted without a value -
<reason>inauthz.error.oauth20(2.4.20.6) is the check that a rejected access token failed:exp,signature,parse,iss,aud,inactive,introspection(no usable answer from the introspection endpoint),remote_user(the claim that names the user is missing) or elseother. A request with an accepted token that does not meet aRequireis counted without a value. Before 2.4.20.6 only the latter was counted: a rejected access token was not counted at all -
<backend>incache.cache.error(2.4.20.4) is the cache backend in use:shm,file,memcacheorredis
Since 2.4.20.5 the <string> in provider.http.connect.error is the generic libcurl text for the error code and no longer the detailed message, which carried the host name.
The measurements are recorded per virtual host in a local in-memory hash table for performance reasons. Each server process flushes its local data to shared memory in a dedicated thread, by default every 5 seconds. Notice that any data consumed on OIDCMetricsPublish is therefore max 5 seconds behind. The shared memory is shared between all of the virtual hosts configured on the same Apache instance. Retrieval of the data on OIDCMetricsPublish returns the counters/timings for all virtual hosts, and resets them only when that is asked for, see Retrieval.
Since 2.4.20.4 two (global) primitives configure the collection; they take precedence over the environment variables that were the only way to set these values before:
OIDCMetricsCacheStorageInterval the flush interval in milliseconds (100-3600000), default 5000;
environment variable: OIDC_METRICS_CACHE_STORAGE_INTERVAL
OIDCMetricsCacheJsonMax the maximum size in bytes (1024-104857600) of the metrics data in shared memory, default 1048576;
environment variable: OIDC_METRICS_CACHE_JSON_MAX
A flush that would exceed that size is dropped: an error is logged and, since 2.4.20.4, it is counted in oidc_metrics_flush_errors, see Prometheus. Raise OIDCMetricsCacheJsonMax when that happens, which is to be expected with a large number of virtual hosts or of distinct counter values.
The OIDCMetricsPublish primitive configures where the data is published. This URL may contain sensitive data and can be protected by any available Apache mechanism (including e.g. AuthType oauth20). This can be done as part of the virtual host that runs mod_auth_openidc but one may also define a separate virtual host in the same Apache server to publish the data, e.g.:
<VirtualHost 192.168.0.200:8080>
OIDCMetricsPublish /metrics
Require ip 192.168
</VirtualHost>Data can be retrieved in a number of formats (see below), using the format query parameter. The counters/timings are not reset on retrieval, unless the parameter reset=true is passed, which every format supports. Before 2.4.20.4 format=json did reset them by default.
Data is only published when at least one virtual host sets OIDCMetricsData: without it a request to the OIDCMetricsPublish path returns a 404 and logs an error (2.4.20.5 and later).
The URL configured in OIDCMetricsPublish returns the collected metrics data in a specified format, passed in the format=<value> query parameter. The following formats are supported, listed with their reset setting default:
-
format=prometheus&reset=false(default)
the Prometheus text-based exposition format -
format=json&reset=false
JSON a custom extended JSON format with descriptions and labels; before 2.4.20.4 its default wasreset=true -
format=status&reset=false
Status a short text response, meant to be used in monitoring/uptime tools such as Nagios: a readiness probe, or the value of a specific counter -
format=internal&reset=false
Internal a terse internal JSON-based representation of the data that is stored in shared memory, without textual labels or descriptions, only used for debugging
A metric is published as oidc_<class>_<name>, with every character of the names listed above that is not a letter or a digit replaced by _: provider.token.error becomes oidc_provider_token_error. Each sample carries the virtual host in a server_name label. A counter that is recorded per value has that value in a value label; the claim counters also have the claim name in a name label:
oidc_provider_http_response_code{server_name="www.example.com",value="200"} 12
oidc_claim_id_token{server_name="www.example.com",name="email_verified",value="true"} 3
A counter that holds samples with a value as well as samples without one publishes the latter as value="_" (2.4.20.6 and later; before that such a counter lost samples).
Since 2.4.20.4 each timer is published as two histogram families:
-
oidc_<class>_<name>_seconds_{bucket,sum,count}, with theleboundaries and the sum in seconds, as is the Prometheus convention -
oidc_<class>_<name>_{bucket,sum,count}, with theleboundaries and the sum in milliseconds: the only family before 2.4.20.4, which is deprecated and will be removed in a future release
Migrate a query such as oidc_provider_token_bucket{le="100"} to oidc_provider_token_seconds_bucket{le="0.1"}.
Since 2.4.20.4 the output starts with three metrics about the module and the metrics collection itself, which are not subject to OIDCMetricsData:
oidc_build_info{version="<version>"} gauge Constant 1, labeled with the version of the module.
oidc_metrics_flush_errors counter Nr of flushes dropped because the metrics data outgrew the shared memory segment.
oidc_metrics_last_flush_timestamp_seconds gauge Unix time of the last completed flush to shared memory.
A value of oidc_metrics_flush_errors that increases means that the published numbers are incomplete, see Collection; a oidc_metrics_last_flush_timestamp_seconds that stops advancing means that they are stale.
Without a counter parameter, format=status is a readiness probe since 2.4.20.4: it writes a value to the configured cache backend, reads it back and reports the result, with the name of the cache backend and the way in which provider metadata is configured (static, metadata_dir or none):
OK
cache: shm: ok
provider: metadata: static
When the cache backend fails, the first line is ERROR, the cache line ends in fail and the HTTP status code is 503. Before 2.4.20.4 the response was a single OK line, whatever the state of the server.
With counter=<metric-name> the response is the single line OK: <counter-value> for that counter, selected with server_name=<vhost>&counter=<metric-name>[&value=<value>][&name=<name>]; server_name defaults to localhost. Without value, a counter that is recorded per value answers with the count that was recorded without one (2.4.20.6 and later). The response is a plain OK when there is no such counter or count (yet).