Skip to content

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.

DeliveryWhen the listener runsWhat a failure does
REQUIREDBefore 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 / spanMetrics resultAudit decisionCounts
PERMITpermitPERMITpermitted requests
TOO_MANY_REQUESTStoo_many_requestsTOO_MANY_REQUESTSpermits an exhausted rate limit stopped (429)
EXPLICIT_DENYexplicit_denyEXPLICIT_DENYrequests a DENY statement refused
IMPLICIT_DENYimplicit_denyIMPLICIT_DENYrequests nothing allowed
SCOPE_REJECTEDscope_rejectedSCOPE_REJECTEDrequests whose app or space the principal may not act in (403 scope-rejected)
BOUNDARYboundaryBOUNDARYpermits outside the tenant's platform boundary (403 forbidden)
INVALID_REQUESTinvalid_requestINVALID_REQUESTrequests that could not be read without ambiguity (400)
INDETERMINATE, AUTHENTICATOR_UNAVAILABLE, DEADLINE_EXCEEDEDindeterminate (cause says which)INDETERMINATErequests no decision could be made for (503)
ERRORerrorERRORdefects (500)
CANCELLEDcancelledno audit recordcallers 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)DeliveryPresent when
LoggingAuditListener (logging-audit)BEST_EFFORTcosec.audit.enabled (default true)
KafkaAuditListener (kafka-audit)cosec.audit.kafka.delivery, BEST_EFFORT by defaultcosec-kafka, a KafkaOperations bean, cosec.audit.enabled and cosec.audit.kafka.enabled (both default true)
MetricsListener (metrics)BEST_EFFORTcosec-micrometer, a MeterRegistry bean (Spring Boot's own auto-configured one included) and cosec.metrics.enabled (default true)
TracingListener (tracing)BEST_EFFORTcosec-opentelemetry
ShadowListener (shadow)BEST_EFFORTcosec-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 at cosec.authorization.shadow.sample-rate, and is offered no other event. When it is the only BEST_EFFORT listener, 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. REQUIRED listeners, and every other listener, receive every event.
  • Break-glass needs a REQUIRED listener. A request permitted through a break-glass binding is 503 unless at least one REQUIRED listener is registered and every one of them records it. Out of the box no listener is REQUIRED, so the starter logs at startup No REQUIRED decision listener is registered: break-glass bindings cannot permit (RFC 0006 §9.4.3). Set cosec.audit.kafka.delivery=required, or register a REQUIRED listener of your own, before you rely on break-glass.
  • One request's events share one id. The event a REQUIRED listener receives and the one a BEST_EFFORT listener receives for the same request carry the same id (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 REQUIRED listener should be idempotent by the event's id: 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 in cosec.listener.dropped, with Decision listeners did not deliver every queued event within <timeout>; <n> were dropped, and no listener call starts any more. at WARN. 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, with The Kafka audit queue of [<topic>] did not drain within <timeout>: <n> queued records are dropped and <n> sends are unanswered. at WARN.
  • The evaluation trace. A DecisionEvent carries evaluationTrace, what the engine looked at, to the depth of cosec.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) or exhaustive (also evaluates the ALLOW pass when the DENY pass decided). It is null at off and 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.

FieldContents
eventId, timestamp, tenantIdthe event; tenantId is the principal's tenant
kindDECIDED, BAD_REQUEST (400), AUTHENTICATION_UNAVAILABLE, CANCELLED or ERROR (500)
principalid, authenticated, roles (the roles of the resolved scope)
requestid (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.reasonCodesee the table below
authorization.reasonthe 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.elapsedNanosthe whole pipeline, from the start of the request to its outcome
authorization.sourcewhat decided: via, document, policy (its id) and statement (index, name); see the second table below
bindinga 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>
snapshotVersionthe revisions the decision read: platform, and app and tenant when it read them
breakGlasswhether the permit came through a break-glass binding
tracetraceId and spanId of the request's span, when tracing is active
OutcomedecisionreasonCode
permitPERMITPERMIT
429TOO_MANY_REQUESTSTOO_MANY_REQUESTS
a DENY matchedEXPLICIT_DENYEXPLICIT_DENY
scope rejectedSCOPE_REJECTEDSCOPE_REJECTED
a permit outside the tenant's boundaryBOUNDARYBOUNDARY
nothing allowedIMPLICIT_DENYIMPLICIT_DENY
any deny of a request whose credential was rejectedas aboveTOKEN_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
400INVALID_REQUESTINVALID_REQUEST (with kind BAD_REQUEST)
503, a strict rate-limit rule that could not be countedINDETERMINATERATE_LIMITER_UNAVAILABLE
any other 503, and a cancelled requestINDETERMINATEINDETERMINATE
500ERRORERROR

authorization.source.via says how what decided came to apply, and document which snapshot document holds it:

viadocumentMeaning
BINDINGPLATFORM, APP or TENANTa 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
ATTACHMENTnulla policy attached through the principal's memberships
BUILTINnullthe built-in blacklist
BOUNDARYPLATFORMthe tenant's platform boundary refused a permit. policy is the boundary and statement is null, since none of its statements matched
NONEnullno 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 in cosec.audit.kafka.failures; what failed before it was queued (a full queue) is in cosec.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 permit 503. Configure the producer with acks=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.

AttributeValue
cosec.tenant_id, user.id, cosec.request_idthe principal's tenant and id, and the request id
cosec.app_id, cosec.space_id, device.idthe resolved scope and the device, when not empty
cosec.authorize.resultPERMIT, 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.namethe deciding statement
cosec.binding.idthe binding it applied through, when it was a binding
cosec.snapshot.versionthe 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:

TagValues
resultwhat 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
sourcebinding, attachment, builtin, boundary, scope (a scope rejection), none
problemwhat 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
causenone, 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:

MeterTagCounts
cosec.listener.droppedlistenerevents a full or closed queue dropped, or a drain that timed out
cosec.listener.failureslistenerlistener calls that threw or, for REQUIRED ones, timed out
cosec.audit.required.failuresnoneREQUIRED failures on decisions they could not change (not permits)
cosec.audit.kafka.failureslistenerbest-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):

MeterTagCounts
cosec.revocation.uncheckednonetokens 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:

MeterTagCounts
cosec.token.cache.hitsnonerequest tokens answered from the cache
cosec.token.cache.missesnonerequest tokens verified because no usable entry was there: first seen, evicted, refused, or outside the instants it is valid at
cosec.token.cache.evictionsnoneentries 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.sizenonea gauge: the entries held

So is the staged list the shadow listener samples by, with shadow windows on (OBS-8):

MeterTagCounts
cosec.shadow.staged.agenonea 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:

MeterTagCounts
cosec.ratelimit.local.refuseddocument: platform, app, tenant, othernew 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:

MeterTagCounts
cosec.problem.render.failednoneevery 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.refusedproblem: 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.refusedrecord: session, change, staging_slot, revision_index, app_list, candidate, shadow_report, instance_status, resident_documents, instance_index, reporters; reason: later, malformedevery 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:

MeterTypeTagsWhat it says
cosec.snapshot.loadscounterkind, resulta 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.durationtimerkind, result = success, failurecompiling 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.installscounterkinddocuments installed: a first load or a new revision
cosec.snapshot.installedgaugekind, statethe 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.laggauge, secondskindthe oldest confirmation by the store among the entries held, failed ones aside
cosec.snapshot.lagginggaugekind, level = warn, escalateentries past the warning threshold, 6 revalidation intervals (those past the escalation threshold included), and past the escalation threshold, 30
cosec.snapshot.summary.agegauge, secondsnonethe time since the pass that installed, lag and lagging read
cosec.snapshot.lag.exceededcounterkind, leveleach lag the instance logs
cosec.snapshot.regressionscounterkindthe store answered an older revision than the one installed
cosec.snapshot.lostcounterkinda document seen before is absent now; its key fails closed
cosec.snapshot.evictionscounterkind, state = document, absententries an app or tenant family dropped at its bound (cosec.snapshot.bound)
cosec.snapshot.boundgaugekind, state = document, absentthe 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.refusedcounterto = housekeeping, callerwork the compile pool refused: caller means a request's thread ran it
cosec.snapshot.housekeeping.refusedcountertask = load-log, compile-log, install-review, effect-log, crash-log, transition-log, prewarm-log, pass-log, reset-log, evict, drop, lag-reporttasks 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 onBecause
any rise of losta document vanished from the store, and its key fails closed
any rise of regressionsthe 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 zeroa 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.refusedthe 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} risingthe 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 cosecSnapshot health indicator is UP once the platform document and every prewarmed document are installed, DOWN before, with the details platform (installed, invalid when it is stored and does not compile, failed, absent or loading), prewarmed, missing, and, when any document does not compile, invalid, how many do not, and invalidFirst, 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, compileTimedOut counts them and compileTimedOutFirst names 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 cosecSnapshotEviction health indicator is DOWN while Redis may evict the snapshot, with an eviction detail that says why. It reports what the instance read last: every node's maxmemory-policy, read every revalidate-interval on a thread of its own, never by a probe. A policy it cannot read is DOWN under eviction-check: fail, and UP with eviction: unknown under warn. 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/health DOWN, 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 cosecControlStoreFormat health indicator is DOWN while its store is in the format before 8.0.0-beta.5, with a format detail naming cosec-migrate repair-references, and UP with format: 8.0.0-beta.5 once 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 is UP with format: unknown. The instance also logs one ERROR when it finds the old format. An alert like cosecSnapshotEviction: the data plane still decides every request, so keep it out of the readiness group (Upgrading). The cosec-control image 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 cosecLoginRoutes health indicator is always UP, with each route's property as a detail: not refused, or denied 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 anonymous POST of it, until a later request is permitted. The same refusal logs one WARN per 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 at ERROR (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>; ..., and Snapshot 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>"). Each last is 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>/propagation answers 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. snapshotVersion in the audit event and cosec.snapshot.version on 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 INFO to the logger me.ahoo.cosec.changelog, as Change <changeId> <kind> on <doc> by <principal>@<tenant>: base=..., candidate=..., escalations=<n>, confirmations=<n>. Change listeners add up: every ChangeListener bean is registered, and the log listener is left out only when the application declares a LoggingChangeListener bean of its own. The change log is written at INFO: a configuration that sets me.ahoo.cosec above INFO sets me.ahoo.cosec.changelog to INFO by name, as for any record you keep.
  • PUBLISHING, BREAK_GLASS_REQUESTED and BREAK_GLASS_APPROVED are gated: every REQUIRED change listener must record the event within cosec.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 answers 503. Every other event, and every event to a BEST_EFFORT listener, is delivered afterwards; a failure is logged as Change 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 (a 409 when the change moved meanwhile), as after a BREAK_GLASS_APPROVED or an ABANDONED. 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 REQUIRED listeners, the first records the gated event and the second times out, so the step answers 503; 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 REQUIRED change listener: without one, creating or changing a break-glass binding answers 503 (break-glass needs a REQUIRED change listener, and none is configured).
  • SHADOW_SKIPPED is written when a window is skipped, with why in its note (shadow window skipped: <reason>; <note>): by :skip-shadow, whose operator holds cosec: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.
  • REBASED is written when a change is rebased on its document's current head and checked again.
  • HEAD_LOST is 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.
  • ABANDONED names who abandoned a change and, in its note, its author (author <tenant>/<principal>: <note>). Abandoning a break-glass change is gated like PUBLISHING: it needs a REQUIRED change listener (503 without one), which records it before the change is stored as abandoned. Abandoning any other change is recorded afterwards.
  • REVOKED of 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 its PUBLISHING.
  • HEADS_MOVED and REVIEW_NEEDED follow a PUBLISHED when 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, or list:apps for 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_MOVED needs nothing; REVIEW_NEEDED means the analysis found an escalation the publish did not have approved, could not run, or the comparison did not finish in time (moved is then empty, and the one escalation has the reason DETECTION_TIMED_OUT): a person should review the published change, and the control plane also logs Change <changeId> published on [<doc>]: <note>; moved [...]. at WARN. 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, reason and detail (Testing changes). A TENANT_BINDINGS one 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 in detail, so an event stays small at any number of tenants. It is informational: it never counts as what needed approval (CTL-48). reason is one of the names of Escalation.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 each REQUIRED listener to record its event, after what was queued before it, within cosec.pipeline.timeout. Otherwise it fails with 503, 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.lost and logged at ERROR (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.lost and logged at ERROR with 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 on cosec.control.listener.lost above 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.dropped and logged at WARN at 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 INFO line 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 WARN names 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. A REQUIRED listener'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., at ERROR for a REQUIRED listener, WARN otherwise), and only then are they stopped. A gated step that arrives during the drain is refused with 503 before it takes effect, as when a REQUIRED listener 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:

MeterWhat
cosec.control.listener.queued, cosec.control.listener.queued.bytesthe events queued, and what they hold, of the listener's share
cosec.control.listener.oldest.agehow long the oldest queued event has waited (seconds): a sink that stopped shows here first
cosec.control.listener.droppedBEST_EFFORT events dropped by a full queue
cosec.control.listener.lostevents 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 ​

LoggerWhat it logs
me.ahoo.cosec.auditthe audit log (Audit log and Kafka)
me.ahoo.cosec.runtimeRequest [<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.snapshotloading, lag, lost and regressed documents (Snapshot health)
me.ahoo.cosec.spring.bootthe 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.changelogthe change log: one INFO line per change event (Control-plane change log); route it as you route me.ahoo.cosec.audit
me.ahoo.cosec.controlControl 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.

Licensed under the Apache License, Version 2.0.