Observability
For operators and security teams who need to know what CoSec decided, why, and who changed the rules. This page covers the decision listeners that observe every request, the audit events, spans and metrics they produce, how to see whether instances are current with the documents, the control plane's change log, and the logs. To see every statement a decision checked, not only the one that decided, explain it through the control plane (Explaining a decision).
Decision listeners
Every request through the pipeline ends in one decision event, whatever its outcome: a permit, a deny, a 429, a 400, a 503, a defect (500), or a caller that went away. Decision listeners receive these events; the audit log, Kafka, metrics, tracing and shadow windows are all listeners. A listener observes only: it cannot change a decision, except that a REQUIRED one that fails turns a permit into 503.
| Delivery | When the listener runs | What a failure does |
|---|---|---|
REQUIRED | Before the response, together with the other REQUIRED listeners, each within 20 % of cosec.pipeline.timeout (1 second at the default) and within what is left of cosec.pipeline.timeout. It sees the outcome as decided so far. | A permit becomes 503 unavailable; the request does not proceed. Any other outcome keeps its status; the failure is logged at ERROR and counted. |
BEST_EFFORT (the default) | After the response is decided, off the request path. Each listener has its own queue, its part of a 64th of the heap counted at 1 KB an event, or 8 KB when cosec.pipeline.trace-level traces (Computed, not configured, 8,192 events each for four listeners on a 2 GiB heap, 1,024 traced), and its own consumer, so a slow listener never costs another its events. It sees the final outcome. | Nothing for the request. A full queue drops the event and counts it, and the request never waits on a log line for it: a reporter logs Dropping decision events: the queue of listener [<name>] is full; <n> dropped since the last report. at WARN, at most every 10 seconds, off the request's thread. A listener that throws is logged at WARN at most every 10 seconds, and counted. |
What decided, in every output
The decision event's outcome.reason names what decided, and every output uses its words (UD-7): the span's cosec.authorize.result as they are, the metrics' result tag in lower case, audit's decision in upper case. Only explicit_deny means a DENY statement refused the request.
outcome.reason / span | Metrics result | Audit decision | Counts |
|---|---|---|---|
PERMIT | permit | PERMIT | permitted requests |
TOO_MANY_REQUESTS | too_many_requests | TOO_MANY_REQUESTS | permits an exhausted rate limit stopped (429) |
EXPLICIT_DENY | explicit_deny | EXPLICIT_DENY | requests a DENY statement refused |
IMPLICIT_DENY | implicit_deny | IMPLICIT_DENY | requests nothing allowed |
SCOPE_REJECTED | scope_rejected | SCOPE_REJECTED | requests whose app or space the principal may not act in (403 scope-rejected) |
BOUNDARY | boundary | BOUNDARY | permits outside the tenant's platform boundary (403 forbidden) |
INVALID_REQUEST | invalid_request | INVALID_REQUEST | requests that could not be read without ambiguity (400) |
INDETERMINATE, AUTHENTICATOR_UNAVAILABLE, DEADLINE_EXCEEDED | indeterminate (cause says which) | INDETERMINATE | requests no decision could be made for (503) |
ERROR | error | ERROR | defects (500) |
CANCELLED | cancelled | no audit record | callers that went away |
The event's subject.method names how the principal authenticated in the words CoSec-Identity uses for the same credential: jwt for CoSec's own token, api-key, service for a service that calls the control plane as its own principal (IDN-34), or the name another verifier's tokens are given (token by default); a principal with no credential is named by its authenticator.
The listeners the starter registers:
Listener (name) | Delivery | Present when |
|---|---|---|
LoggingAuditListener (logging-audit) | BEST_EFFORT | cosec.audit.enabled (default true) |
KafkaAuditListener (kafka-audit) | cosec.audit.kafka.delivery, BEST_EFFORT by default | cosec-kafka, a KafkaOperations bean, cosec.audit.enabled and cosec.audit.kafka.enabled (both default true) |
MetricsListener (metrics) | BEST_EFFORT | cosec-micrometer, a MeterRegistry bean (Spring Boot's own auto-configured one included) and cosec.metrics.enabled (default true) |
TracingListener (tracing) | BEST_EFFORT | cosec-opentelemetry |
ShadowListener (shadow) | BEST_EFFORT | cosec-cocache and cosec.authorization.shadow.enabled (default true) |
Any DecisionListener bean of yours joins them; names must be unique, or startup fails (Extending). An AuditEventSink bean joins them too: the starter wraps it as a BEST_EFFORT listener named after the bean (AuditListener.of(sink, beanName)), in its @Order among the listeners. It is always BEST_EFFORT, because AuditEventSink.publish cannot acknowledge a write. A bean that is both is registered once, as the DecisionListener it is.
- The shadow listener sees only the requests it samples (
OBS-8). It samples only requests that read a document the staged list names, then atcosec.authorization.shadow.sample-rate, and is offered no other event. When it is the onlyBEST_EFFORTlistener, a request it does not sample makes no decision event at all, so with no shadow window open a host without metrics, tracing or audit listeners does nothing for it on a request.REQUIREDlisteners, and every other listener, receive every event. - Break-glass needs a
REQUIREDlistener. A request permitted through a break-glass binding is503unless at least oneREQUIREDlistener is registered and every one of them records it. Out of the box no listener isREQUIRED, so the starter logs at startupNo REQUIRED decision listener is registered: break-glass bindings cannot permit (RFC 0006 §9.4.3).Setcosec.audit.kafka.delivery=required, or register aREQUIREDlistener of your own, before you rely on break-glass. - One request's events share one
id. The event aREQUIREDlistener receives and the one aBEST_EFFORTlistener receives for the same request carry the sameid(the BEST_EFFORT one adds what the REQUIRED listeners' failures were), so an audit store and a metrics pipeline can join them, and either can drop a redelivery. - A
REQUIREDlistener should be idempotent by the event'sid: a write that timed out may still have succeeded. - The BEST_EFFORT event never fails a request. It is made after the outcome exists; if making it throws (a shadow listener's sampler, say), the event is counted as dropped by every BEST_EFFORT listener (
cosec.listener.dropped) and the request keeps its answer. - On shutdown, the listeners stop taking events, and the events already queued are still delivered for up to a sixth of
spring.lifecycle.timeout-per-shutdown-phase(5 seconds at the default). Then no listener call starts any more: a call in progress is not interrupted, and what is left is dropped and counted incosec.listener.dropped, withDecision listeners did not deliver every queued event within <timeout>; <n> were dropped, and no listener call starts any more.atWARN. The Kafka audit listener then gets up to the same timeout for the sends it still holds and the broker's answers to them, before the producer is closed. At that bound its queued sends are dropped and a send in progress is interrupted, withThe Kafka audit queue of [<topic>] did not drain within <timeout>: <n> queued records are dropped and <n> sends are unanswered.atWARN. - The evaluation trace. A
DecisionEventcarriesevaluationTrace, what the engine looked at, to the depth ofcosec.pipeline.trace-level:off(the default, no trace and no cost),full(every statement of every candidate is listed, with what ruled it out; evaluation stops where it would without a trace, except that it finishes the pass that decided) orexhaustive(also evaluates the ALLOW pass when the DENY pass decided). It is null atoffand when the request did not reach the engine. Only your own listeners read it: the audit events, spans and metrics below do not include it. - Services in gateway mode (
cosec.pipeline.mode=gateway) emit no decision events: they decide nothing and register no listeners. The gateway in front records the decision (Deploying the gateway server).
Audit events
The audit listeners map each decision event to an AuditEvent. It keeps what the response body leaves out: explicit and implicit denies apart, why a credential was rejected, and why a request was 503.
| Field | Contents |
|---|---|
eventId, timestamp, tenantId | the event; tenantId is the principal's tenant |
kind | DECIDED, BAD_REQUEST (400), AUTHENTICATION_UNAVAILABLE, CANCELLED or ERROR (500) |
principal | id, authenticated, roles (the roles of the resolved scope) |
request | id (the CoSec-Request-Id), appId, spaceId, remoteIp, method, path (normalized), routeId (the gateway route the request came through; null on other adapters), device.id |
authorization.decision, authorization.reasonCode | see the table below |
authorization.reason | the outcome, and for a 503 its cause, such as INDETERMINATE: SourceUnavailable. A cause has one name wherever CoSec writes it, here, in a shadow report's samples and in the control API's cause, taken from one table, so renaming a class in CoSec does not change it (OBS-9) |
authorization.elapsedNanos | the whole pipeline, from the start of the request to its outcome |
authorization.source | what decided: via, document, policy (its id) and statement (index, name); see the second table below |
binding | a label for people, and not to be parsed: how the deciding statement applied, as a binding id (a role's derived binding is role:<roleId>@<app>:<permission>), attached:<policyId>, builtin (the blacklist) or boundary:<tenantId> |
snapshotVersion | the revisions the decision read: platform, and app and tenant when it read them |
breakGlass | whether the permit came through a break-glass binding |
trace | traceId and spanId of the request's span, when tracing is active |
| Outcome | decision | reasonCode |
|---|---|---|
| permit | PERMIT | PERMIT |
429 | TOO_MANY_REQUESTS | TOO_MANY_REQUESTS |
| a DENY matched | EXPLICIT_DENY | EXPLICIT_DENY |
| scope rejected | SCOPE_REJECTED | SCOPE_REJECTED |
| a permit outside the tenant's boundary | BOUNDARY | BOUNDARY |
| nothing allowed | IMPLICIT_DENY | IMPLICIT_DENY |
| any deny of a request whose credential was rejected | as above | TOKEN_EXPIRED, TOKEN_REVOKED or TOKEN_INVALID (also for an API key); DELEGATION_UNSUPPORTED for a token with an act claim, which the response reports as token-invalid. TOKEN_NOT_YET_VALID for a token whose iat or nbf is later than this instance's clock beyond the skew (IDN-29), which the response reports as token-invalid too. The principal stays anonymous; authorization.reason names whose credential was refused when that is known (a key that does not work, a principal the membership provider does not know or knows as deactivated), as the decision event's subject.refused does |
400 | INVALID_REQUEST | INVALID_REQUEST (with kind BAD_REQUEST) |
503, a strict rate-limit rule that could not be counted | INDETERMINATE | RATE_LIMITER_UNAVAILABLE |
any other 503, and a cancelled request | INDETERMINATE | INDETERMINATE |
500 | ERROR | ERROR |
authorization.source.via says how what decided came to apply, and document which snapshot document holds it:
via | document | Meaning |
|---|---|---|
BINDING | PLATFORM, APP or TENANT | a binding of that document, a role's derived binding included; binding is its id. A break-glass permit is a binding of cosec:root, with breakGlass: true |
ATTACHMENT | null | a policy attached through the principal's memberships |
BUILTIN | null | the built-in blacklist |
BOUNDARY | PLATFORM | the tenant's platform boundary refused a permit. policy is the boundary and statement is null, since none of its statements matched |
NONE | null | no statement decided: nothing allowed the request, its scope was rejected, or no decision was made. policy and statement are null |
Audit log and Kafka
The audit log listener writes each event as one JSON line to the logger me.ahoo.cosec.audit: PERMIT at DEBUG, denials (the deny kinds and INVALID_REQUEST), TOO_MANY_REQUESTS and INDETERMINATE at WARN, ERROR at ERROR. At the default INFO level, only denials, 503s and errors appear.
The Kafka audit listener writes the same JSON to cosec.audit.kafka.topic (cosec-audit), keyed by [tenantId, principalId] as a JSON array. It runs alongside the audit log, not instead of it; set cosec.audit.enabled=false and register only what you want to change that. It sends from a thread of its own, with as many sends waiting as its decision queue holds: its part of the decision listeners' share of the heap (Computed, not configured). A full send queue fails the send at once.
best-effort: failed sends are logged at most once every 10 seconds, with how many failed since the last line:Failed to publish audit event to Kafka topic [<topic>]: <n> failed since the last report.(a broker outage is one line per interval, not one per decision). Each record the broker refused, or never answered, after it was queued is counted incosec.audit.kafka.failures; what failed before it was queued (a full queue) is incosec.listener.failures.required: the request waits for the broker's acknowledgement. A failed or late send, or a full send queue (The Kafka audit queue of [<topic>] is full.), makes a permit503. Configure the producer withacks=all.
Tracing
With cosec-opentelemetry, each decision event becomes a span named cosec.authorize (instrumentation me.ahoo.cosec, kind INTERNAL). The span is made after the decision, from the request's start time and the pipeline's duration, under the span that was current when the adapter received the request; without one, it is a root span. Tracing therefore never delays or fails a request. Calls the pipeline makes for the request (Redis, a membership provider) are siblings of cosec.authorize, under the same parent. The tracer comes from GlobalOpenTelemetry. The span inherits the parent's tracestate as the SDK's own child spans do. The event's trace carries it as an opaque string in its W3C header form: vendor data that CoSec writes onto the span's parent and nowhere else (not into audit records, Kafka records, logs or metric tags), and that a decision listener of yours must not log. A value the SDK refuses, or one longer than 512 characters, is no tracestate: the span is still made, under the same parent.
| Attribute | Value |
|---|---|
cosec.tenant_id, user.id, cosec.request_id | the principal's tenant and id, and the request id |
cosec.app_id, cosec.space_id, device.id | the resolved scope and the device, when not empty |
cosec.authorize.result | PERMIT, TOO_MANY_REQUESTS, EXPLICIT_DENY, IMPLICIT_DENY, SCOPE_REJECTED, BOUNDARY, INDETERMINATE, AUTHENTICATOR_UNAVAILABLE, DEADLINE_EXCEEDED, INVALID_REQUEST, CANCELLED or ERROR |
cosec.authorize.policy.id, cosec.authorize.statement.index, cosec.authorize.statement.name | the deciding statement |
cosec.binding.id | the binding it applied through, when it was a binding |
cosec.snapshot.version | the revisions read, as <platform>/<app>/<tenant>, - for a document not read |
A 500 sets the span's status to ERROR. Audit events and problem bodies carry the trace id of the request's span, which ties a response to its trace.
Startup summary
Once every bean exists, the starter logs one INFO line of what CoSec is configured as, for example CoSec 8.0.0-beta.8: mode=enforce, web=servlet-filter, jwt=on (JwtTokenVerifier), token-cache=on (max-bytes=134217728), revocation-reader=the CoCache token store's (CoCacheRevocationReader), login=on, api-keys=off, rate-limiter=ReactiveRedisRateLimiter, listeners=[tracing, logging-audit], route-map=12 routes. Each entry is what a request meets, resolved as the authenticator resolves it: the revocation reader is the application's bean, the CoCache token store's, or RevocationReader.NONE, which the line spells out because revoked tokens are then accepted until they expire; with no token verification (jwt=off) there is no reader to name. token-cache says whether a request's token is answered from the verified-token cache: off when configured off, or for a TokenVerifier bean of your own. When the application declares an Authenticator bean, it replaces the starter's (extending): the line then says authenticator=<class> (replaces CoSec's: tokens, revocation and API keys are its own) and lists no jwt, revocation-reader or api-keys, since none of them is in force. A switch written false is added as switched-off-by-configuration=[...]. A rate limiter named LocalRateLimiter counts per instance: with several instances the limit is multiplied by their number. When cosec.enabled=false the line is one WARN instead: CoSec is off ... nothing is protected by CoSec (troubleshooting).
A host that runs the control plane logs one more INFO line once it has started: what the control plane serves and where its callers come from, for example Control plane: HTTP routes on /cosec/control (port 8080; service port 8082), caller from the forwarded identity (statement: only-trusted-callers-can-reach), or, in an application that reaches it in process only, Control plane: no HTTP routes (cosec.control.http.enabled=false), caller from the credential. The ports are the ones the servers bound.
Metrics
With cosec-micrometer and a MeterRegistry (for example from Spring Boot Actuator), every decision event is recorded by the timer cosec.authorization, over the whole pipeline. Every tag has a small fixed set of values, so the number of time series stays bounded however many policies, apps and tenants there are:
| Tag | Values |
|---|---|
result | what decided (every output's words): permit, too_many_requests, explicit_deny (a DENY statement, and only that), implicit_deny, scope_rejected, boundary, invalid_request (400), indeterminate (every 503), cancelled, error |
source | binding, attachment, builtin, boundary, scope (a scope rejection), none |
problem | what the client was told: unauthorized (401, anonymous), token-invalid, token-expired, token-revoked (401), forbidden, scope-rejected (403), too-many-requests, invalid-request, unavailable, internal-error, or none when the request proceeds or was cancelled |
cause | none, and on indeterminate: source_unavailable, document_invalid, missing_policies, membership, attribute, matcher, authenticator, required_listener, boundary, rate_limiter, deadline, unknown |
On the cosec-gateway-server image the registry is Prometheus's and the endpoint is /actuator/prometheus on the management port (8081), never on the gateway's port (the image). The tag values above are the whole of CoSec's; no tenant, principal, path or token is ever a tag.
The listeners themselves are counted:
| Meter | Tag | Counts |
|---|---|---|
cosec.listener.dropped | listener | events a full or closed queue dropped, or a drain that timed out |
cosec.listener.failures | listener | listener calls that threw or, for REQUIRED ones, timed out |
cosec.audit.required.failures | none | REQUIRED failures on decisions they could not change (not permits) |
cosec.audit.kafka.failures | listener | best-effort Kafka audit records lost after they were queued: the broker refused them or never answered. While the broker is down every record is lost here and cosec.listener.failures stays still until the queue fills: alert on any |
So are the tokens the pipeline accepted without a revocation check, the revocation store unreadable (the documented exception):
| Meter | Tag | Counts |
|---|---|---|
cosec.revocation.unchecked | none | tokens accepted while their revocations could not be read; each such stretch also logs Token revocations cannot be read: tokens are accepted without a revocation check (<n> so far). at WARN, at most every 10 seconds |
So is the verified-token cache, while it is on:
| Meter | Tag | Counts |
|---|---|---|
cosec.token.cache.hits | none | request tokens answered from the cache |
cosec.token.cache.misses | none | request tokens verified because no usable entry was there: first seen, evicted, refused, or outside the instants it is valid at |
cosec.token.cache.evictions | none | entries removed to stay within the token cache's share of the heap; a steady rate means the share is smaller than the tokens in use at once: give the instance more heap |
cosec.token.cache.size | none | a gauge: the entries held |
So is the staged list the shadow listener samples by, with shadow windows on (OBS-8):
| Meter | Tag | Counts |
|---|---|---|
cosec.shadow.staged.age | none | a gauge, in seconds: how long ago this instance last read the staged list, NaN before its first read. About the report interval (a sixth of the status's life, 10 s) while Redis answers; rising, the list cannot be read, the instance reads every candidate by its key and logs The staged list cannot be read since it was at <instant> once |
With the local rate limiter (no Redis rate limiting, Rate limiting), so are the new buckets it could not admit:
| Meter | Tag | Counts |
|---|---|---|
cosec.ratelimit.local.refused | document: platform, app, tenant, other | new buckets refused because the rule's, its document's or the whole bound was full: each is a request a strict rule answered 503 or a lenient one did not limit; the log line is written at most every 10 seconds |
Alert on the rate of result=indeterminate by cause, on explicit_deny (requests a DENY statement refused), on cosec.listener.dropped, and on any rise of cosec.revocation.unchecked: while it rises, a revoked token is accepted. A cosec.shadow.staged.age above three report intervals is an instance that samples by a list it no longer reads. A rise of indeterminate with cause=source_unavailable means documents cannot be read, and with cause=document_invalid that a stored document does not compile on this instance (Troubleshooting). CoCache records its own meters for CoSec's caches in the same registry (CoCache's documentation).
A service in gateway mode (cosec.pipeline.mode=gateway) has no pipeline and records no decision events, so none of the meters above. It counts the forwarded identities it refuses:
| Meter | Tag | Counts |
|---|---|---|
cosec.problem.render.failed | none | every refusal answered with CoSec's own body because the application's ProblemRenderer threw or answered no bytes (PIP-34); the request was still refused, with CoSec's status. Any non-zero rate is a renderer to fix (Troubleshooting) |
cosec.identity.refused | problem: invalid-request, token-invalid, token-expired, unavailable (a member crit names that the service does not know: a reader older than its writer, IDN-41) | every CoSec-Identity header the service refused, including those its log does not print; the reason is logged at WARN, at most once a minute for each problem (Troubleshooting), never in the response |
cosec.stored.refused | record: session, change, staging_slot, revision_index, app_list, candidate, shadow_report, instance_status, resident_documents, instance_index, reporters; reason: later, malformed | every stored record the reader's rule refused (OBS-12): later for one a later version wrote (a later format, or a member its crit names that this version does not know), expected during a rolling upgrade and over once every instance runs the later version; malformed for one that is not a record of its kind, a store to look at (Storage, Troubleshooting) |
In gateway mode any non-zero rate means a hop that is misconfigured or a request that did not come through the gateway; alert on it.
Snapshot metrics
Under the same conditions as the timer (cosec-micrometer, a MeterRegistry, cosec.metrics.enabled), the starter meters the data plane's snapshot source: the documents this instance reads, compiles and holds (How instances read documents). The control plane's own source is not metered. A Pipeline an application builds itself gets none of these meters. No tag carries an app or tenant id, so there are 80 series whatever the number of documents. kind is platform, app or tenant:
| Meter | Type | Tags | What it says |
|---|---|---|---|
cosec.snapshot.loads | counter | kind, result | a request that had to load a document: cold (the request waited for its load), failed (the load failed, and the request is decided fail-closed), timeout (the load outlasted the cold-load timeout). A request that finds its documents installed is not counted: that is every request's path |
cosec.snapshot.compile.duration | timer | kind, result = success, failure | compiling a document; failure is a stored document that does not compile on this instance, or a compilation that did not end within its load's budget (recorded with the time the load had taken, again at each load that meets that revision still compiling, and once more, as it ends, when it ends) |
cosec.snapshot.installs | counter | kind | documents installed: a first load or a new revision |
cosec.snapshot.installed | gauge | kind, state | the entries held now, by state: present, invalid (does not compile here), pending (its inputs changed and it waits for its compile again), undecodable, absent (no document, none seen before), lost (a document seen before is gone), unreadable. The states add up to what the instance holds |
cosec.snapshot.lag | gauge, seconds | kind | the oldest confirmation by the store among the entries held, failed ones aside |
cosec.snapshot.lagging | gauge | kind, level = warn, escalate | entries past the warning threshold, 6 revalidation intervals (those past the escalation threshold included), and past the escalation threshold, 30 |
cosec.snapshot.summary.age | gauge, seconds | none | the time since the pass that installed, lag and lagging read |
cosec.snapshot.lag.exceeded | counter | kind, level | each lag the instance logs |
cosec.snapshot.regressions | counter | kind | the store answered an older revision than the one installed |
cosec.snapshot.lost | counter | kind | a document seen before is absent now; its key fails closed |
cosec.snapshot.evictions | counter | kind, state = document, absent | entries an app or tenant family dropped at its bound (cosec.snapshot.bound) |
cosec.snapshot.bound | gauge | kind, state = document, absent | the bound each family is held to now, derived from a quarter of the heap and recomputed from what is resident each revalidation pass and before each eviction (SNP-24); beside cosec.snapshot.installed |
cosec.snapshot.handoffs.refused | counter | to = housekeeping, caller | work the compile pool refused: caller means a request's thread ran it |
cosec.snapshot.housekeeping.refused | counter | task = load-log, compile-log, install-review, effect-log, crash-log, transition-log, prewarm-log, pass-log, reset-log, evict, drop, lag-report | tasks the source's housekeeping thread refused because its queue (4,096) was full. Each was dropped, except drop (an empty entry's removal), which ran in place. A *-log is a log line that was not written; evict an eviction pass under the family's cap, which the next load asks for again; install-review a host's review of an installed document (the route map warning), offered again when a later read finds that revision still installed |
installed, lag and lagging are as of the source's last lag pass, run every revalidate-interval, not read on a scrape: a scrape costs a read of one field however many documents there are. They read zero before the first pass, when summary.age is NaN; a summary.age far above revalidate-interval means the passes have stopped.
The share of requests that waited for a document is loads{result=cold} over the decisions (the count of cosec.authorization); evictions says why it rises.
| Alert on | Because |
|---|---|
any rise of lost | a document vanished from the store, and its key fails closed |
any rise of regressions | the store lost a write it acknowledged: check the last failover |
any rise of lag.exceeded{level=escalate} | the instance decides on a document the store has not confirmed for 30 revalidation intervals |
installed{state=invalid} above zero | a stored document does not compile on this instance (an older version than the control plane?) |
a sustained rate of handoffs.refused{to=caller} | the compile pool is saturated, and requests' threads compile |
any rise of housekeeping.refused | the instance is dropping its own log lines: a log appender too slow for the load (Snapshot log lines are missing) |
a sustained rate of evictions, with loads{result=cold} rising | the families are too small for the traffic: installed stays at bound; give the instance more heap, since the bounds are a quarter of it (Sizing a SaaS gateway) |
Snapshot health
The meters above count; the health indicators and logs below answer whether an instance is current:
- Health. With Spring Boot Actuator, the
cosecSnapshothealth indicator isUPonce the platform document and every prewarmed document are installed,DOWNbefore, with the detailsplatform(installed,invalidwhen it is stored and does not compile,failed,absentorloading),prewarmed,missing, and, when any document does not compile,invalid, how many do not, andinvalidFirst, the first ten of them with their stored revisions, the platform first and then by key (["tenant:acme@7"]), never the compiler's message. When the compilation of a revision did not end within its load's budget and still runs,compileTimedOutcounts them andcompileTimedOutFirstnames the first ten in the same order and form: the instance decides on the revision it held before, and the status does not change (A compilation does not end). Readiness follows the same condition (Readiness). - Eviction. On Redis, the
cosecSnapshotEvictionhealth indicator isDOWNwhile Redis may evict the snapshot, with anevictiondetail that says why. It reports what the instance read last: every node'smaxmemory-policy, read everyrevalidate-intervalon a thread of its own, never by a probe. A policy it cannot read isDOWNundereviction-check: fail, andUPwitheviction: unknownunderwarn. It is an alert, not a readiness signal: keep it out of the readiness group, where one change to Redis would take every instance out of rotation while requests are still decided (Redis requirements). It also turns the aggregate/actuator/healthDOWN, as every indicator does: point load balancers and platform health checks at the readiness group, or leave it out of the group they poll (management.endpoint.health.group.<group>.exclude=cosecSnapshotEviction). - Control store format. Where the control plane runs over CoCache, the
cosecControlStoreFormathealth indicator isDOWNwhile its store is in the format before 8.0.0-beta.5, with aformatdetail namingcosec-migrate repair-references, andUPwithformat: 8.0.0-beta.5once it has run. It reports what the instance read last, every minute on a thread of its own, never by a probe; one it cannot read isUPwithformat: unknown. The instance also logs oneERRORwhen it finds the old format. An alert likecosecSnapshotEviction: the data plane still decides every request, so keep it out of the readiness group (Upgrading). Thecosec-controlimage is the exception: it decides no request of the data plane, and puts the indicator into its readiness group, so that an unconverted store leaves the host unready and named (The control-plane host). - Login routes. When the starter serves the refresh or logout route, the
cosecLoginRouteshealth indicator is alwaysUP, with each route's property as a detail:not refused, ordenied since <time>and which refusal it was (no statement permits it, a DENY statement matches it, or the tenant's platform boundary does not cover it) once a document refused an anonymousPOSTof it, until a later request is permitted. The same refusal logs oneWARNper route per minute, naming the property and the path. Both come from the decisions of real requests, so they are never wrong, and neither makes the instance unready (Building a client). - Lag logs. An instance logs a document not confirmed by Redis for longer than 6 revalidation intervals at
WARN, and longer than 30 atERROR(How instances read documents). Other lines to alert on:Snapshot document [<doc>] disappeared from the store; failing closed.,Snapshot document [<doc>] regressed from revision <a> to <b>; ..., andSnapshot prewarm failed for [<docs>]; retrying in <backoff>. - Housekeeping summary. The source writes its log lines and runs its eviction passes on one housekeeping thread, so a slow appender never holds a request's thread. When that thread's queue is full, or once it has stopped as the source closes, a task is dropped and counted instead of run on the thread that offered it; the source's own threads still run theirs while it closes. At most every 10 seconds, and only when something was dropped or a meter threw, the thread logs one
WARN, and a closing source writes what is left once, on the thread that closes it:Snapshot housekeeping since its last summary: refused <n> tasks, full or stopped (each dropped; drop runs in place): load-log 3 (last: "<text>"), …; meter failures <n> (last: "<text>").Eachlastis the text of the last line of that task that was dropped, with its exception's class and message but no stack, cut at 256 characters. A meter that throws is never logged on its own: it is counted here, so the summary is written whatever registry is bound. - Propagation. The control plane's
GET /documents/<doc>/revisions/<n>/propagationanswers how many of the instances that reported in the last minute have revision<n>or later installed. An instance counts a revision as installed only while it can evaluate it: one that read the revision but could not compile it still reports, so it is among those counted, but it has not installed it. Instances report only with shadow windows on (Revisions, history and rollback). - Per decision.
snapshotVersionin the audit event andcosec.snapshot.versionon the span name the revisions a decision read.
Control-plane change log
The control plane emits a change event for every step of a change: PROPOSED, CHECKED, SHADOW_STARTED, SHADOWED, APPROVED, REJECTED, PUBLISHING, PUBLISHED, FAILED, BREAK_GLASS_REQUESTED, BREAK_GLASS_APPROVED, REVOKED, HEADS_MOVED, REVIEW_NEEDED, ABANDONED, SHADOW_SKIPPED, REBASED, and HEAD_LOST, which no step writes. Every route that changes a change's record writes one when it does (CTL-63). An event names the change, the document, the operator, the base and candidate revisions, what needed approval, the confirmations, the shadow summary and the note; it never carries a document's content. Change listeners receive them. An event also carries the origin of its step's operator (CTL-57), as the event's JSON writes it: asserted (the host believed the identity the caller stated instead of verifying a credential itself), via (the credential's method, its id as credential and the request's id as request, never its value) and peer (the address of the connection the request arrived on, read from the Reactor Netty channel beneath any forwarded-header handling, so that a caller cannot state it as it states its client address; a host that cannot read it that way, any but Reactor Netty, records none, and so the control API of a Servlet host (WebMvc) records no peer). A step made through the control plane's facade, in the host's own process (Changing policies from your code), is via.method: in-process, with the credential's id when there is one and no peer, since no connection carried it. A step no request drives, a maintenance pass for one, has none; the stored change records the origin of its author, and the log line ends with origin=... when there is one.
asserted: true says the rest of via is the caller's own words. On a host that believes the identity it is stated (the control-plane host, an IAM service that embeds the control plane), the caller writes the whole identity: the credential's method (jwt included, which makes the principal it states break-glass capable as a verified token would), the credential's id, and the request id, which is the CoSec-Request-Id it sent. The record keeps what was stated and marks it asserted: read via.method, via.credential and via.request of such an origin as what the caller said, not as what the host verified. Only an origin without asserted names a credential the host verified itself.
- The default listener logs each event at
INFOto the loggerme.ahoo.cosec.changelog, asChange <changeId> <kind> on <doc> by <principal>@<tenant>: base=..., candidate=..., escalations=<n>, confirmations=<n>. Change listeners add up: everyChangeListenerbean is registered, and the log listener is left out only when the application declares aLoggingChangeListenerbean of its own. The change log is written atINFO: a configuration that setsme.ahoo.cosecaboveINFOsetsme.ahoo.cosec.changelogtoINFOby name, as for any record you keep. PUBLISHING,BREAK_GLASS_REQUESTEDandBREAK_GLASS_APPROVEDare gated: everyREQUIREDchange listener must record the event withincosec.pipeline.timeout(5 seconds at the default, for all of them together) before the step takes effect, or the step does not happen and the control API answers503. Every other event, and every event to aBEST_EFFORTlistener, is delivered afterwards; a failure is logged asChange listener [<name>] could not record <event>.The revision record is the durable record of what was published. A gated event says the step was about to happen, not that it did: a check after it can still refuse the step (a409when the change moved meanwhile), as after aBREAK_GLASS_APPROVEDor anABANDONED. The change's state, and for a publish the revision history, say what happened.- The stream over-reports; it never under-reports a step that took effect. An event can be recorded for a step that then did not take effect: with two
REQUIREDlisteners, the first records the gated event and the second times out, so the step answers503; a check after the event refuses the step (a lost compare-and-set); a send that timed out completes afterwards. A consumer reconciles each event with the change's record (GET /changes/{id}, and the revision history for a publish) before it treats the step as done. - A note is free text, part of it the change's author's (the reason of a proposal, a request or a revoke): read who did a step from the event's
operator, never from its note. - Break-glass needs a
REQUIREDchange listener: without one, creating or changing a break-glass binding answers503(break-glass needs a REQUIRED change listener, and none is configured). SHADOW_SKIPPEDis written when a window is skipped, with why in its note (shadow window skipped: <reason>; <note>): by:skip-shadow, whose operator holdscosec:skip-shadow, or by a break-glass change, which has no window. It is written whether or not the change is ever published; the revision's provenance records the skip too, once it publishes. A refused skip writes nothing.REBASEDis written when a change is rebased on its document's current head and checked again.HEAD_LOSTis written when a revision a change published is not on its document's head chain: its head write was lost, as a Redis failover loses one (CTL-86). The reclamation pass finds one listed above the head; a read of the history that rebuilds the index from the head (once a publish reused the number) finds one it is about to drop. The operator is who published it, the base the head now, the candidate the lost revision. Each instance writes it once for a revision it finds. The change is not in effect: publish it again or roll back.cosec.control.revisions.lost(counter, no tags) counts them: alert on any.ABANDONEDnames who abandoned a change and, in its note, its author (author <tenant>/<principal>: <note>). Abandoning a break-glass change is gated likePUBLISHING: it needs aREQUIREDchange listener (503without one), which records it before the change is stored as abandoned. Abandoning any other change is recorded afterwards.REVOKEDof a stalled revoke published again names the revoker who revoked again, and its note adds their reason (<first reason>; published again by <tenant>/<principal>: <reason>), as does itsPUBLISHING.HEADS_MOVEDandREVIEW_NEEDEDfollow aPUBLISHEDwhen another document the change was checked with moved before its write landed (What a publish compares). Each names the heads that moved (moved: the document, orlist:appsfor the app list, the digest it was checked with, the digest it has now, and whether it could be read), carries the escalations the grant analysis finds on the current heads, and says in its note what that means.HEADS_MOVEDneeds nothing;REVIEW_NEEDEDmeans the analysis found an escalation the publish did not have approved, could not run, or the comparison did not finish in time (movedis then empty, and the one escalation has the reasonDETECTION_TIMED_OUT): a person should review the published change, and the control plane also logsChange <changeId> published on [<doc>]: <note>; moved [...].atWARN. They are recorded even when the client that published disconnects. Like every event that is not gated, they are best effort: the publish has already happened.- Escalations in an event are
subject,reasonanddetail(Testing changes). ATENANT_BINDINGSone stands for every tenant a widened permission policy reaches: one per policy (tenants binding [<policy>] in app <app>), with the statements, the count and the first 20 tenant documents indetail, so an event stays small at any number of tenants. It is informational: it never counts as what needed approval (CTL-48).reasonis one of the names ofEscalation.Reason.
With cosec-kafka and a KafkaOperations bean, the starter also registers a KafkaChangeListener, unless cosec.control.audit.kafka.enabled is false. It writes each event to cosec.control.audit.kafka.topic (cosec-control-audit), keyed by the document (platform, app:order, tenant:acme), so a document's events stay in order. Its delivery is cosec.control.audit.kafka.delivery: best-effort by default, required to gate publishing and break-glass on the broker's acknowledgement (configure the producer with acks=all). With delivery=required, startup fails when the Kafka change listener cannot be created (no cosec-kafka, no KafkaOperations bean, or enabled=false), rather than publishing without the record: cosec.control.audit.kafka.delivery=required, but no Kafka change listener was created: ....
Order and queues
A listener receives one change's events in the order this instance wrote them (CTL-66): each listener has one queue and one consumer, and a step's event is queued after its earlier steps'. Across instances there is no order to keep (a propose on one control host and a publish on another are two processes): a consumer orders by each event's time and the change's record. The Kafka change listener's per-document key then keeps that order in its partition.
- A gated step (
PUBLISHING, break-glass) waits for eachREQUIREDlistener to record its event, after what was queued before it, withincosec.pipeline.timeout. Otherwise it fails with503, and its event is not recorded afterwards. - A REQUIRED listener's full queue makes the event of any other step wait for room, for at most the same timeout, in the order the events came: a smaller one never takes room ahead of a larger one waiting before it. The step is already stored, so it is never failed for this. An event that finds no room in time is lost: counted in
cosec.control.listener.lostand logged atERROR(Change event <kind> of change <id> on <doc> was not handed to REQUIRED change listener [<name>]: ...). - A REQUIRED listener's failed call loses the event of any other step too: one that throws, or does not answer within the timeout. It is counted in the same
cosec.control.listener.lostand logged atERRORwith the failure (Change event <kind> of change <id> on <doc> was not recorded by REQUIRED change listener [<name>]: <failure>.), and the next event is delivered. A full queue and a failed call are the two ways a REQUIRED listener misses an event: alert oncosec.control.listener.lostabove zero. - A BEST_EFFORT listener's full queue drops the incoming event, so what arrives is an ordered prefix: a consumer sees a gap, never a reordering. Drops are counted in
cosec.control.listener.droppedand logged atWARNat most once per required timeout. - The bound is derived, not configured. The queues hold together at most a thirty-second of the heap, shared equally by the listeners, each event measured from what it holds. One
INFOline at startup says what that came to (Change listeners [...]: their queues hold at most 64.0 MB (the heap's 2048.0 MB / 32), 32.0 MB each). A healthy sink keeps its queue near empty, even through a bulk change of thousands of tenants. - A listener that stops answering is reported, never cut off. While events wait and it has delivered nothing for longer than the required timeout, a
WARNnames it, its depth and the age of the oldest event, at most once per required timeout. What its share held is delivered, in order, when it answers again. AREQUIREDlistener's call that does not answer within the timeout is a failed call (above), and its next event is delivered. - At shutdown the listeners drain within a sixth of
spring.lifecycle.timeout-per-shutdown-phase, the decision listeners' timeout. They stop taking events and deliver what is queued; what is left is counted and logged per listener (Change listener [<name>] never records <n> change events: they were still queued when the drain of <timeout> ended., atERRORfor aREQUIREDlistener,WARNotherwise), and only then are they stopped. A gated step that arrives during the drain is refused with503before it takes effect, as when aREQUIREDlistener cannot record it. Any other step is already stored: its event is logged the same way, never queued to be lost.
Meters, each tagged listener:
| Meter | What |
|---|---|
cosec.control.listener.queued, cosec.control.listener.queued.bytes | the events queued, and what they hold, of the listener's share |
cosec.control.listener.oldest.age | how long the oldest queued event has waited (seconds): a sink that stopped shows here first |
cosec.control.listener.dropped | BEST_EFFORT events dropped by a full queue |
cosec.control.listener.lost | events of stored steps a REQUIRED listener missed, its queue full or its call failed: alert on any |
cosec.control.shadow.status.unreadable (no tags) counts the instance statuses a control host read that did not decode: each such instance holds every shadow window until its status reads or expires (CTL-73), and the log names it (Troubleshooting). Alert on any.
cosec.control.revisions.records and cosec.control.revisions.bytes (gauges, no tags) are the revision records the documents retain and their stored bytes, and cosec.control.changes.open the open changes (CTL-84). The reclamation pass sets them, every hour: only the instance that holds the pass's lease reads every document, so only it reports what it found, replacing its values when the pass ends and reporting the last pass's until then (no 0 in between). An instance another one led the pass for reports 0; one whose pass could not start (the documents could not be listed) keeps what it last found. Take the largest across instances: it is the store's total as of the last pass. A sum can count one pass twice, for the pass after the lease changes hands. A document that pass skipped (an open change that does not read) is not counted, and bytes counts an entry an older version wrote only once a pass sized it. Alert on bytes approaching what Redis may hold.
cosec.control.revisions.reclaimed-young (counter, no tags) counts the records an instance reclaimed younger than min-age, past what a document may retain (CTL-84): a document publishing large documents in a loop. Alert on any, and look for the WARN that names the document (Troubleshooting).
cosec.control.work.held (gauge, bytes) is what this host's control calls hold of its work budget now, and cosec.control.work.refused (counter) the calls it refused 503 for want of room (CTL-85): large documents proposed, applied or explained at once. Each host has its own budget, so read them per host. A refusal now and then under a burst is the bound working; a steady rate means the host needs more heap or the large writes need spreading out (Troubleshooting).
Logs
| Logger | What it logs |
|---|---|
me.ahoo.cosec.audit | the audit log (Audit log and Kafka) |
me.ahoo.cosec.runtime | Request [<requestId>] failed with an unmodelled exception. at ERROR with the stack trace, for every 500; REQUIRED listener failures; dropped events; attribute providers that fail (<provider> failed to fetch [...] at WARN, at most every 10 seconds per provider: each decision carries the cause); rate limiters that cannot count; The staged list cannot be read since it was at <instant>: candidates are read by their keys until it can. at WARN, once per outage of the shadow windows' staged list (CTL-47, Storage) |
me.ahoo.cosec.runtime.snapshot | loading, lag, lost and regressed documents (Snapshot health) |
me.ahoo.cosec.spring.boot | the startup checks, such as the !!! eviction warning; No BlacklistSource bean: requests are not checked against a blacklist (ext.blacklist.*). at INFO when the application declares no BlacklistSource (Blacklist); ip2region databases: [<versions>]. at INFO, naming the IP versions without a database, whose addresses are unavailable; the WARN of a service in gateway mode (Services behind the gateway) |
me.ahoo.cosec.changelog | the change log: one INFO line per change event (Control-plane change log); route it as you route me.ahoo.cosec.audit |
me.ahoo.cosec.control | Control API <method> <path> failed (request <requestId>). for every control-plane 500; and, under the logger of the class that writes it, Change listener [<name>] could not record <event>. at WARN |
Correlate a response with its log lines, audit event and span through the CoSec-Request-Id response header, which is also the requestId of every problem body.
Next: go from a symptom to its cause, in Troubleshooting.