reference deployersecurity-reviewer

Reading a deployment’s own numbers — the metrics scrape contract

In plain words: this deployment already counts things — email deliveries, payments it gave up trying to confirm, applications stuck waiting on a payment, checks it sent to other institutions’ registers, how deep its background queue is, how close its database connections are to running out, how many separate accounts used it this month, how much traffic it is serving and how fast, and whether anybody is blocked right now. Nothing used to offer those counts to anyone. Each of the two running programs (the web app and the background worker) now opens a small doorway inside its own container, on a port reachable only from inside this deployment’s private network — never from the public internet. This page tells a country’s own monitoring how to read that doorway: which of the two programs to ask for which number, and the several places a naive setup gets a wrong answer.

Nothing here requires Prometheus or Grafana to be installed for this platform to work. This is a contract for a country that chooses to run its own monitoring — an optional extra, not a dependency.


The two targets

TargetAddress (inside the deployment network)PathAuth
Appopengov:9100/metricsnone
Workerworker:9100/metricsnone

Both are the plain Prometheus text exposition format. Neither is published on a host port and neither is routed by the public host router — see docs/reference/deployment-architecture.md §8. Reading one from a shell-less container:

docker compose exec worker python3 -c \
  "import urllib.request as u; print(u.urlopen('http://127.0.0.1:9100/metrics').read().decode())"

No authentication, no rate limiting, no security headers. The whole exposure model rests on the port being unreachable from outside the deployment’s own Docker network — nothing else guards it. If a country’s network topology ever changes so that assumption no longer holds (a flat network across tenants on a shared host, for example), treat this listener as fully public and revisit before relying on it.

Why two targets, and why it matters more than it looks

Neither target alone answers an operator’s questions, and the split is not where a reader would guess. Queue depth, backlog age and the census of where every filing sits are counted in the worker — the app declares those names and never sets them, so an app-only scrape misses every signal an operator needs at 3am. Traffic and the deployment’s own health verdict go the other way: they are counted in the app, because that is the process that answers requests and runs the health timer. And one family is not a split at all: each program keeps its own pool of database connections, so both targets publish a real and different number about a different thing, and neither pinning one nor adding them up is right. Both targets must be in the Prometheus config, with different job labels, so a query can pin the target that actually owns each metric (the per-metric rules are below).

Example prometheus.yml

scrape_configs:
  - job_name: opengov-app
    static_configs:
      - targets: ["opengov:9100"]
  - job_name: opengov-worker
    static_configs:
      - targets: ["worker:9100"]

Per-target ownership

Measured directly from each process’s own Prometheus registry (the method tests/platform/test_metrics_process_split.py re-runs on every change, so this table cannot silently drift from the code). _total/_bucket suffixes are what Prometheus appends to a Counter/Histogram at scrape time — the bare names below are the registry’s own names.

App target (opengov:9100)

  • opengov_build_info — always 1; labels (component, version, git_sha) identify which release this target is
  • eapproval_applications_by_status — where every filing currently sits; worker-authoritative, no samples on this target
  • eapproval_applications_never_submitted — filings started and never sent, by status; worker-authoritative, no samples on this target
  • eapproval_applications_registered — filings registered, the definitive yes (dual-emitted — see below)
  • eapproval_applications_submitted — filings handed to the agency, by which door (dual-emitted, split by label — see below)
  • eapproval_distinct_applicants — how many separate accounts filed inside each window; worker-authoritative, no samples on this target
  • eapproval_document_checks — documents checked before sending, by result, cause and model copy. It counts applicant checks only: the operator’s look (opengov.eapproval.document_check.look) never adds to it. The applicant’s check route sets it here
  • eapproval_payment_held_applications — registered here but never set here; worker-authoritative, no samples on this target
  • eapproval_payment_hold_oldest_age_seconds — same: worker-authoritative, no samples on this target
  • eapproval_refusals — definitive refusals, by how far the refusal reaches (dual-emitted — see below)
  • eapproval_role_info — always 1; maps an officer step’s id to the name agency staff gave it; worker-authoritative, no samples on this target
  • eapproval_step_duration_seconds — how long one visit to one step lasted, by kind of step; worker-authoritative, no samples on this target
  • eapproval_time_to_registration_seconds — submission-to-registration wait (dual-emitted — see below)
  • eapproval_work_queue_depth — filings waiting on each officer step; worker-authoritative, no samples on this target
  • eapproval_work_queue_oldest_filing_age_seconds — how long the longest-waiting filing on each officer step has been with the agency; worker-authoritative, no samples on this target
  • eapproval_work_queue_overdue — work-queue entries past their step’s deadline; worker-authoritative, no samples on this target
  • integration_event_admin_override — admin-override actions on integration events
  • notification_dispatch_attempted — dispatch attempts leased (dual-emitted — see below)
  • notification_dispatch_outcome — terminal outcome of a dispatch attempt (dual-emitted — see below)
  • notification_dlq_depth — dead-letter backlog gauge (worker-authoritative — see below)
  • notification_emit_failure — swallowed fan-out failures (dual-emitted — see below)
  • notification_outbox_lag_seconds — drain-backlog age (worker-authoritative, the trap — see below)
  • notification_rate_limit_rejections — dispatches rejected at the rate-limit gate (dual-emitted — see below)
  • notifications_health_refresh_lag_seconds — seconds since the last health-snapshot refresh
  • notifications_health_snapshot_refresh_duration_seconds — wall-clock duration of one refresh pass
  • notifications_inbox_deadline_auto_read_refused — auto-mark-read refusals on acknowledgement-required deliveries
  • opengov_background_job_duration_seconds — seconds one background job took to run, by task; worker-authoritative, no samples on this target
  • opengov_background_jobs_finished — background jobs that finished, by task and by how they ended; worker-authoritative, no samples on this target
  • opengov_db_pool_connections_idle — database connections open and unused in this process’s pool (per-target, never summed — see below)
  • opengov_db_pool_connections_in_use — database connections this process has handed out right now (per-target, never summed — see below)
  • opengov_db_pool_max_overflow — extra connections this process may open during a burst (per-target, never summed — see below)
  • opengov_db_pool_size — the steady number of connections this process keeps (per-target, never summed — see below)
  • opengov_health_blocking_components — how many parts are stopping somebody right now; app-only (see below)
  • opengov_health_component_state — one series per part per state, 1 for the state it is in and 0 for the rest; app-only
  • opengov_health_degraded — 1 when something is wrong and nobody is blocked by it; app-only
  • opengov_health_snapshot_max_age_seconds — how old the checks’ answer may get before this deployment stops trusting it; app-only
  • opengov_health_snapshot_timestamp_seconds — Unix time the checks last ran; app-only
  • opengov_http_request_duration_seconds — seconds to answer a request, by route shape (declared in both, counted here — see below)
  • opengov_http_requests — requests answered, by route shape, method and status class (declared in both, counted here — see below)
  • payments_checkout_initiated — server-signed checkout descriptors assembled
  • payments_confirmation_failed — payments the platform stopped trying to confirm, by why it stopped (declared in both, counted in the worker — see below)
  • payments_confirmation_lag_seconds — checkout-to-confirmation lag
  • payments_intents_needing_attention — payments parked for a person right now, by why; worker-authoritative, no samples on this target
  • payments_intents_voided — payments an administrator cancelled, by the state they were cancelled from (declared in both, counted here — see below)
  • payments_ipn_token_rejected — inbound payment notifications refused on a per-intent token mismatch
  • payments_reconcile_divergence — provider status-query disagreed with the observed ledger
  • smartlink_external_check — checks sent to an outside register, by how each one ended (dual-emitted — see below)
  • smartlink_external_check_duration_seconds — seconds a check spent on the wire (dual-emitted — see below)
  • smartlink_external_check_failure — checks against an outside register that did not succeed, by reason (dual-emitted — see below)
  • smartlink_inbound_response — inbound provider-notification responses by kind
  • vault_draft_changes — answers to a draft change (a save that sends only the change of an unfinished form), by outcome. The app registers it when the vault is on. The worker does not register it

Worker target (worker:9100)

  • opengov_build_info — same self-identification gauge as the app target
  • eapproval_applications_by_status — the real, authoritative census of where every filing sits
  • eapproval_applications_never_submitted — the real count of filings started and never sent, by status
  • eapproval_applications_registered — the claim reaction’s own emission (dual-emitted — see below)
  • eapproval_applications_submitted — the after-a-fee release’s own emission (dual-emitted, split by label — see below)
  • eapproval_distinct_applicants — the real, authoritative count of separate accounts that filed inside each window
  • eapproval_document_checks — declared here because the worker imports eapproval/metrics.py, never set here: the worker never checks a document
  • eapproval_payment_held_applications — applications currently held on a payment gate
  • eapproval_payment_hold_oldest_age_seconds — age of the oldest held application
  • eapproval_refusals — the claim reaction’s own emission (dual-emitted — see below)
  • eapproval_role_info — the real, authoritative map from a step’s id to its published name
  • eapproval_step_duration_seconds — the real, authoritative timing of one visit to one step, by kind of step
  • eapproval_time_to_registration_seconds — same (dual-emitted — see below)
  • eapproval_work_queue_depth — the real, authoritative queue depth per officer step
  • eapproval_work_queue_oldest_filing_age_seconds — the real, authoritative age of the longest-waiting filing on each step
  • eapproval_work_queue_overdue — the real count of entries past their step’s deadline
  • notification_dispatch_attempted — the periodic dispatch pass’s own emission (dual-emitted — see below)
  • notification_dispatch_outcome — same (dual-emitted — see below)
  • notification_dlq_depth — the real, authoritative dead-letter backlog gauge
  • notification_emit_failure — the drain’s own emission (dual-emitted — see below)
  • notification_outbox_lag_seconds — the real, authoritative drain-backlog gauge
  • notification_rate_limit_rejections — same (dual-emitted — see below)
  • notifications_health_refresh_lag_seconds — the periodic refresh’s own emission
  • notifications_health_snapshot_refresh_duration_seconds — same
  • notifications_inbox_deadline_auto_read_refused — same
  • opengov_background_job_duration_seconds — the real, authoritative time each background job took to run
  • opengov_background_jobs_finished — the real, authoritative count of jobs that finished, by task and by how they ended
  • opengov_background_queue_jobs — background jobs in each live queue state; worker-only, the app does not declare the name
  • opengov_background_queue_oldest_waiting_age_seconds — how long the oldest due background job has waited; worker-only, the app does not declare the name
  • opengov_db_pool_connections_idle — database connections open and unused in this process’s pool (per-target, never summed — see below)
  • opengov_db_pool_connections_in_use — database connections this process has handed out right now (per-target, never summed — see below)
  • opengov_db_pool_max_overflow — extra connections this process may open during a burst (per-target, never summed — see below)
  • opengov_db_pool_size — the steady number of connections this process keeps (per-target, never summed — see below)
  • opengov_http_request_duration_seconds — declared here, never set here (app-authoritative — see below)
  • opengov_http_requests — declared here, never set here (app-authoritative — see below)
  • payments_checkout_initiated — the reconciliation job’s own emission
  • payments_confirmation_failed — the real, authoritative count of give-ups (declared in both, counted here — see below)
  • payments_confirmation_lag_seconds — same
  • payments_intents_needing_attention — the real, authoritative population parked for a person
  • payments_intents_voided — declared here, never set here (app-authoritative — see below)
  • payments_ipn_token_rejected — same
  • payments_reconcile_divergence — same
  • smartlink_external_check — the verification job’s own emission (dual-emitted — see below)
  • smartlink_external_check_duration_seconds — same (dual-emitted — see below)
  • smartlink_external_check_failure — same (dual-emitted — see below)

integration_event_admin_override and smartlink_inbound_response are app-only: both fire on the synchronous request path (an admin’s mark-handled click; an inbound provider POST), and the worker never imports the route modules that define them.

The five opengov_health_* measurements are app-only in the stricter sense: the worker does not even declare the names. The checks that decide whether a person is blocked run on a timer the web app starts at boot (main.py’s lifespan), and only that timer writes them. Registering them in the worker would publish an unlabelled zero meaning “nobody is blocked” from a process that ran no check, and a last-refreshed time of 1970 — so the worker target simply has nothing to say about health, which is the honest answer. A query needs no job pin: only one target ever carries these names.

The two background-queue measurements are worker-only in that same stricter sense, and are the first names that run this way round: the app does not declare them. Nothing on the web app’s import graph reaches the census that counts the queue, and that is deliberate — an unlabelled age gauge nobody writes would read 0 from the app, meaning “nothing has waited at all” about a queue the app never looked at. Only one target carries these names, so a query needs no job pin.

The eApproval gauges are no longer worker-only in the registry. The lifecycle counters put eapproval/metrics.py into the web process too, so the app target now declares every eapproval_* name. Only the worker’s periodic passes ever give the gauges a value — the two payment-hold ones, the four census ones, and the count of separate accounts that filed. Every one of them carries a label the app never sets, so the app target prints their names with no samples underneath: a query pinned to the app job returns no data, not a reassuring zero. Pin {job="opengov-worker"} on all of them.

payments_intents_needing_attention is the same shape for the same reason: the app declares it because it imports payments/metrics.py, and only the worker’s hourly sweep ever writes it. Pin {job="opengov-worker"}.


Read this before writing a query — where each answer really lives

opengov_health_blocking_components — the whole verdict, one query

Is anybody blocked right now? One number answers it, with nothing to join against and no target to pin:

opengov_health_blocking_components > 0

Zero is exactly what the health page reports as ok. Anything above zero is an outage somebody is living through. Which part, and what it stops them doing, is the next query and still needs no join — the answer travels on the labels:

opengov_health_component_state{state=~"down|unknown"} == 1

Two things that look alike and are not, kept as separate states on purpose. unknown means a check ran and did not answer — an outage on a part that blocks people. not_checked means nobody has written a check for that part yet — a known gap, and never a reason to wake anyone. A query that treated them as one would either scream about every unwritten check or read a dropped one as green.

Trust the answer only if it is fresh. The timestamp is published as a moment, so the reader does the subtraction and a dead timer shows up as an ageing answer rather than a permanently fresh one:

time() - opengov_health_snapshot_timestamp_seconds
  > opengov_health_snapshot_max_age_seconds

opengov_http_requests_total — declared in both, counted in one

The traffic pair (this counter and opengov_http_request_duration_seconds) has a shape no other metric here has. Both processes declare the names, because both import the request middleware that defines them — but only the web app answers requests, so only the web app ever increments them. The worker target therefore prints both names with no samples underneath, forever.

That is a different failure from the outbox trap below: there is no frozen zero to mislead anyone, because a metric with no samples returns no data rather than a reassuring number. It still means a query that forgets to pin the job is reading one target that can never contribute. Pin {job="opengov-app"} on both.

sum(rate(opengov_http_requests_total{job="opengov-app", status="5xx"}[5m]))
  / sum(rate(opengov_http_requests_total{job="opengov-app"}[5m]))

notification_outbox_lag_seconds — the trap

This is an unlabelled Gauge. Both processes define it (importing the module registers it), but only the worker’s periodic drain ever calls set_outbox_lag(...) — the app process never touches it, so its own copy sits frozen at 0.0 forever. A Prometheus config that scrapes only the app target, or a query that averages across both targets, reads “no backlog” — including during a real backlog. This is the single most likely way a correctly-built system gives an operator a wrong answer.

Always pin {job="opengov-worker"} on this metric. Never avg() or sum() it across jobs.

notification_emit_failure_total — the opposite case

This one is genuinely dual-emitted from two different code paths: the app’s own request-path fan-out (notifications/service.py) and the worker’s outbox drain (notifications/outbox.py). A query pinned to one job misses half the failures. Sum across both jobs instead:

sum(rate(notification_emit_failure_total[5m]))

eapproval_applications_submitted_total — one count, two processes

The applicant pressing submit is counted in the app; the release after a fee clears is counted in the worker. The entry label says which (direct / after_payment), and the two never appear on the same target. A procedure that charges a fee produces after_payment only — so a query pinned to the app job reports zero submissions for it. Sum across both jobs:

sum by (entry) (rate(eapproval_applications_submitted_total[1h]))

The same applies to eapproval_applications_registered_total, eapproval_refusals_total and eapproval_time_to_registration_seconds: registrations and refusals are usually decided in the worker (the claim reaction runs there), but the correction-resubmit route can register an application inside the app process. Sum both jobs; never pin one.

Two more things to know before reading these four. They are counted in process memory outside the database transaction, so a rollback after the count leaves the number one too high until the process restarts — they answer “roughly how much, and which way is it moving”, and the database stays the authority for any number that has to be exact. And eapproval_time_to_registration_seconds records only journeys that ended in a yes: a filing that was refused, abandoned, or is still in review contributes nothing, and a registered filing that never passed the submit door (a seeded or harness one, with no submission timestamp) is skipped — so the histogram’s own count is legitimately lower than the registrations counter.

The same “sum across both jobs, never pin one” rule applies to every other metric marked dual-emitted above — notification_dispatch_attempted, notification_dispatch_outcome, notification_rate_limit_rejections, payments_checkout_initiated, payments_confirmation_lag_seconds, payments_ipn_token_rejected, payments_reconcile_divergence, notifications_health_refresh_lag_seconds, notifications_health_snapshot_refresh_duration_seconds, notifications_inbox_deadline_auto_read_refused, and the three smartlink_external_check* names — each fires from more than one call site across the two processes (a request-path emission in the app, a periodic-task emission in the worker, or both), so restricting to one job undercounts.

A check against an outside register is one call this platform makes to another institution’s system to confirm something an applicant claimed — asking the tax authority whether a taxpayer number exists, asking the company register who owns a company. Those calls start in both processes: an administrator’s test on the connector screen and an applicant’s own lookup run in the app, while the automated verification behind a filing runs in the worker. Neither target sees all of them. Sum both jobs:

sum by (connector) (rate(smartlink_external_check_failure_total[15m]))

Every register that has been checked at least once publishes all three outcomes and all eleven reasons at zero, so a register behaving perfectly reads 0 rather than returning no data — the difference between “none of them failed” and “nobody asked”. A register never checked at all in a given process is absent there, which is the honest answer.

Two readings that look like the register failing and are not. Our own per-register call limit refusing to dial is reason="throttled_locally", never the register’s fault; a register that genuinely answers “too many requests” arrives as counterpart_4xx. And a check refused before anything was sent — a broken field mapping, a sign-in that failed, our own call limit — records no time on the wire at all, so the fastest bucket of smartlink_external_check_duration_seconds is never padded with calls that never left the building.

payments_confirmation_failed_total and payments_intents_voided_total — the same shape, opposite directions

Both are declared by both processes and written by only one, and it is not the same one. The platform giving up on establishing whether a fee arrived is decided by the reconciliation job, in the worker. A payment an administrator cancelled is decided on the admin screen, in the app. Pin accordingly:

sum by (reason) (rate(payments_confirmation_failed_total{job="opengov-worker"}[1h]))
sum by (from_state) (rate(payments_intents_voided_total{job="opengov-app"}[1h]))

Neither number says the money was lost. This platform only ever knows whether it managed to ask the provider; whose books hold the money is the provider’s answer, not ours. payments_intents_needing_attention is the matching population — how many are parked for a person right now — and it is worker-authoritative, so pin {job="opengov-worker"} there too.

One near-collision worth knowing before writing an alert: the give-up counter spells its exhausted-retries reason retries_exhausted, and the parked-payment gauge spells its own retry_exhausted. They are different label values on different measurements, and a regular expression written for one silently matches nothing on the other.

opengov_db_pool_connections_in_use — per-target, and neither pin nor sum

The four connection-pool readings are the one family here that is genuinely a different fact on each target. A connection pool is the small, fixed set of open database connections a process hands out to whatever needs one; when they are all in use the next piece of work simply waits, and from the outside the deployment feels slow with nothing in the logs to say why. The web app and the background worker each keep their own pool, so job is not a detail to pin away — it is part of the answer. Adding the two together describes nothing that exists. Read each target on its own:

opengov_db_pool_connections_in_use
  / (opengov_db_pool_size + opengov_db_pool_max_overflow)

Left ungrouped, that returns one series per target, which is what an operator wants: either process can exhaust its pool while the other is idle. The three inputs are read at the moment of scraping, straight out of memory — no database call, no timer, and nothing added to any request path.

Two deliberate omissions, both of which would have read as good news. The database library’s own overflow counter starts at minus the pool size, so a healthy idle pool reports -10; publishing it would put a negative number on a dashboard and make every saturation formula built on it wrong, which is why connections in use is published instead — right at every moment, cold pool included. And a process whose pool kind has no occupancy to report — the kinds tooling and tests use — publishes nothing at all rather than four zeros, because four zeros read as an empty, healthy pool rather than as “this process cannot answer”.

opengov_background_queue_jobs — depth is not the whole answer

Until these two measurements a deployment could say the background worker was alive and never whether it was keeping up. Only the second is visible to an applicant waiting for something to happen.

state takes three values: waiting (queued and due now — the backlog), not_due_yet (queued but held for later, which is what a job that failed and is backing off looks like), and running. Depth alone cannot separate a busy queue from a stuck one, which is what the age gauge is for — a deep queue that is draining is fine, and a shallow queue whose oldest job has waited ten minutes is not:

opengov_background_queue_oldest_waiting_age_seconds > 600

Both are worker-only, so no job pin is needed. Two honest caveats: the census counts itself — its own job is running while it runs, so running is never zero during a pass — and neither number says whether background work is succeeding. Counting permanently-failed jobs would need an index on a table this platform does not own (see the named gaps below).

Because the “always pin one job” rule, the “always sum both jobs” rule and the “read each target separately” rule all pull in different directions per metric, there is no single blanket instruction — this table is the answer, not a shortcut around it.


opengov_background_jobs_finished_total — the ending the queue gauges cannot show

The queue gauges above answer “keeping up?”. This answers “did the work actually happen?”, and the reason it needs its own measurement is worth stating plainly: a job that runs out of retries leaves every state those gauges count. It stops waiting, stops being held for later, stops running. The queue reads healthier at the exact moment work is permanently lost.

outcome takes four values, and collapsing any two of them would hide the one that matters:

valuewhat happenedwhat to do
succeededthe work happenednothing
retryingit failed; it will be attempted againwatch a sustained rate
gave_upit failed; nothing will try againact — the work never happened and nobody was told
abortedthe worker was shut down mid-jobnothing; this is what a redeploy does

aborted exists so an ordinary deployment does not read as data loss. On a deployment that redeploys on every merge it is the commonest abnormal ending, and counting it as lost work would keep the alert permanently lit.

Nothing is queried to produce this. Counting permanently-failed jobs by grouping the job runner’s own table was measured and rejected — see the named gaps below — so each job is counted as it ends, in the worker that ran it.

Every (task, outcome) pair this release defines is published as a zero before the first job runs. Without that, a deployment where nothing has failed publishes no failure series at all and

rate(opengov_background_jobs_finished_total{outcome="gave_up"}[5m])

answers “no data” — which on a dashboard is indistinguishable from “nothing failed”. Alert on the rate being above zero; do not add or vector(0) to an alert, only to a panel.

One ending this cannot see: a job whose task no longer exists in the running code. The job runner raises before any middleware runs, so nothing counts it. It is named in the gaps below rather than papered over.


eapproval_work_queue_oldest_filing_age_seconds — depth was never the whole answer

The same argument the background queue already made, applied to an officer’s desk. Depth says how many filings are waiting; it never says for how long. Ten filings at a desk that turns them over hourly is a working desk. Two that have sat since Tuesday is a stuck one, and the depth gauge reads the second as healthier than the first.

The deadline gauge beside it (eapproval_work_queue_overdue) only answers for steps whose procedure set a deadline at all. A step that promised nothing can never be late, so without this a whole class of desks had no staleness signal whatsoever.

Read the clock carefully. The age is measured from when the filing reached the agency, not from when it reached this desk. Nothing records the second: the work-queue table is rebuilt whole every time an application moves, so no arrival stamp survives on it. A filing that has crossed four desks in a day reports a one-day age at the fourth, not the hours it has spent there. The metric is named for what it measures rather than for what one might wish it measured.

Capped like the two gauges beside it, sharing one ranking so the three charts agree about which desks exist — and folded into the other bucket by worst age, never by sum. Adding ages would report a wait nobody had, and would make the bucket climb as steps were added rather than as anything got worse.


eapproval_role_info — how to make a chart of desks readable

Every step measurement is keyed by role, which is a UUID an agency’s own tooling minted. A chart of “which desk has the biggest queue” therefore answers 8239a268-11ce-41b0-a98d-6da93a0def21, which is no answer at all to the person reading it. This publishes the name beside the id:

sort_desc(
  sum by (role) (eapproval_work_queue_depth{job="opengov-worker"})
  * on (role) group_left(role_name) eapproval_role_info{job="opengov-worker"}
)

then legend on {{role_name}}. The same join works on every role-keyed measurement.

Why the name is not simply a second label on the queue gauges. A label value is part of a series’ identity. An agency renaming “Legal Review” to “Legal Check” would silently start a new series and orphan the history of the old one — the chart would show a desk appearing from nowhere and another going quiet on the day somebody edited a word. The id never moves; the name changes freely here.

Cleared and rewritten each pass alongside the gauges it explains, and capped by the same ranking, so it never carries a name for a desk that has no series. A step whose published procedure could not be read falls back to its own id — unhelpful on a chart, but truthful, and better than a row vanishing from the join. The bucket of quiet desks is named all other steps.


eapproval_step_duration_seconds — one visit to one step, and why it is not per desk

The whole journey was already timed (eapproval_time_to_registration_seconds). This times one stint at one step, so “which kind of step is slow” stops being a database question.

It is labelled by the kind of step, never by the step itself, and that is not a convenience. Step ids come from agency-authored procedures and are unbounded. The work-queue gauges make them safe by clearing and re-ranking every pass, keeping the busiest desks and folding the rest — machinery a histogram cannot use, because a histogram cannot be cleared. A step id here would accumulate one permanent series per step ever seen, in every deployment, for ever. node_type is closed at three: verification, automation, convergence.

Two honest caveats. A step reopened by a correction round starts a fresh measurement rather than continuing the first — a second visit to a desk is a second stint of work, and adding them would describe a wait nobody had. And only a step that genuinely opened and then completed is timed; a step whose branch of the procedure was never taken contributes nothing, which is why the count here is lower than the number of steps a procedure declares.


Labels

  • channel — email (Phase 2D; sms is a future phase). Cardinality: 1 today.
  • outcome — four unrelated meanings, one per metric family; never group by it across families. On the notification metrics it is how one delivery attempt ended: delivered, failed_permanent, failed_transient, rate_limited, suppressed (cardinality 5). On smartlink_external_check_total it is how one check against an outside register ended: ok, failed, timed_out (cardinality 3, fixed — the words come from the same status mapping written on the check’s own audit row, so a dashboard and the administrator’s screen can never disagree about what counts as a failure). On opengov_background_jobs_finished_total it is how one background job ended: succeeded, retrying, gave_up, aborted (cardinality 4, fixed in code). Note the four vocabularies share no word between them, which is deliberate: a query written for one family returns nothing rather than something wrong if pointed at another.
    • On vault_draft_changes_total it is how the vault answered one draft change. The code in vault/metrics.py fixes its 14 values. Seven are answers: applied, changes_off, malformed, too_large, too_many_saves, card_not_found, older_than_erase. Six are the causes of a change that does not fit: other_version, other_key, no_draft, missing_place, not_a_container, duplicate_row_key. The last value, other, counts a value outside this list.
  • deployment — a deployment’s short code (e.g. tst-dep). One value per install (self-hosted, per-country) — cardinality 1 in production.
  • deployment_id — the same deployment as a UUID, used by the notifications-health metrics. Not the same value space as deployment — see the dashboard note below.
  • country — settings.country_code. One value per install.
  • kind — on the integration-event metric, admin_override or admin_override_revoked; on the two payment-hold gauges, at_submission or before_approval. Cardinality: 2 per metric.
  • entry — direct (the applicant pressed submit) or after_payment (a fee cleared and the hold released). Cardinality: 2.
  • finality — field (one requirement refused for good; the filing continues but can never register) or application (the whole filing closed). Cardinality: 2.
  • status — two unrelated meanings, one per metric family; never group by it across families. On eapproval_applications_by_status it is where a filing sits: draft, awaiting_payment, awaiting_prerequisites, submitted, in_review, corrections_requested, registered, rejected, refused, revoked, recalled, blocked_by_upstream_rejection, withdrawn_before_submission, plus other for anything a later release adds (cardinality 14, fixed). On opengov_http_requests_total it is the class of the answer a request got — 1xx, 2xx, 3xx, 4xx, 5xx, plus other for a code outside 100–599 that this platform never returns (cardinality 6, fixed). The exact code is deliberately not kept: what an operator alerts on is the failing fraction, and the code itself is already on every request line in the operational log.
  • route — the declared shape of an address, /api/v1/eapproval/applications/{application_id}, never the address actually requested: that carries the identifier of somebody’s file, and a query string can carry their details outright. One value per route this platform declares (app.openapi() prints the exact set), plus two literals — unmatched for a backend address no route owns and static for a page and its files. Fixed by the code, so it moves only when a release declares a new route; nothing a caller sends can add a value.
  • method — GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, plus other. Cardinality: 8, fixed. The eighth value is the load-bearing one: the method is whatever text the caller wrote on the request line, and a stranger’s LOLWUT-9000 is answered 405 carrying the real route shape, so without the fold anyone able to send a request could mint series without limit.
  • role — an officer step id from a published procedure. Agency-authored, so it is capped in code (eapproval/metrics.py’s MAX_ROLE_SERIES): the deepest queues keep their own series and the rest are summed into other. Cardinality: 51, fixed.
  • role_name — what agency staff called an officer step, on eapproval_role_info alone. Free text an agency writes, so it is truncated to 120 characters — a label has to stay a label. Cardinality does not multiply: exactly one name per step already published, plus all other steps for the capped bucket. Never put this on a measurement: renaming a step would start a new series and orphan its history, which is the whole reason it lives apart.
  • node_type — the kind of step, on eapproval_step_duration_seconds: verification (a person decides), automation (a bot decides), convergence (a meeting point where branches rejoin). Cardinality: 3, fixed by the procedure vocabulary. Deliberately carries the kind because the step itself cannot be a label here — see that metric’s own note.
  • task — the name of a background job, on the two opengov_background_job* measurements. Fixed by the code: one value per job this release defines, plus other for a job deferred under a name a later release renamed away, which arrives off a database row and must not be free to mint series. Cardinality: one per registered task + 1.
  • response_kind — accepted, classified, or fault. Cardinality: 3.
  • environment — sandbox or live, plus unknown on the two payment counters (payments_confirmation_failed_total, payments_intents_voided_total) for the case where the payment or its provider binding could no longer be read at all. Cardinality: 3 on those two, 2 everywhere else. Fixed in code either way.
  • connector — the short code of one outside register, on the three smartlink_external_check* measurements. An administrator chooses these codes, so the set is not closed and is capped in code (smartlink/metrics.py’s MAX_CONNECTOR_SERIES = 30): the first thirty registers seen keep their own series and every later one is folded into other. Cardinality: 31, fixed. A real deployment runs five to twenty, so the fold is not expected to fire — it exists so the count cannot run away if one day it does. The operation within a register is deliberately not a label: it is agency-authored per register, so pairing the two would multiply one open set by another. The per-operation breakdown already exists as an administrator’s screen.
  • reason — three unrelated value spaces, one per metric; never group by it across them. On smartlink_external_check_failure_total it is why a check against an outside register did not succeed: ten come from the failure taxonomy the executor already classifies (network_unreachable, timeout, auth_rejected, counterpart_4xx, counterpart_5xx, malformed_response, transform_error, signature_error, success_condition_false, outcome_unknown — the request may have run but its answer is lost; alert on it, a person must reconcile it) plus throttled_locally (our own call limit refused to dial — the register was never contacted) and unclassified (cardinality 12, fixed). On payments_confirmation_failed_total it is why the platform stopped trying: retries_exhausted, intent_missing, binding_missing (cardinality 3, fixed). On payments_intents_needing_attention it is why a payment is parked for a person: currency_mismatch, divergence, retry_exhausted, degraded_accept, confirmed_decrease, plus unknown so a row written by older code can never open the set (cardinality 6, fixed). Note retries_exhausted and retry_exhausted are different words on different measurements.
  • from_state — on payments_intents_voided_total, the state a cancelled payment was cancelled from: unpaid, partially_paid, plus other as the fold. Cardinality: 3, fixed. The service refuses to cancel from any other state — money has already moved — and the fold is there so a future caller past that guard could not mint one series per payment state.
  • window — on eapproval_distinct_applicants, the stretch of time the count covers: 24h, 7d, 30d. Cardinality: 3, fixed. Each is a rolling window, never a calendar one — 30d is the last thirty days, so somebody counted today drops out thirty days after they filed. All three come from one pass over the filings, so the second and third cost nothing beyond the first.
  • state — two unrelated value spaces, one per metric; never group by it across them. On opengov_health_component_state it is how a part of the deployment is doing: up, down, unknown (a check ran and did not answer), not_checked (nobody has written a check for that part yet) — cardinality 4, fixed. The last two look alike and mean opposite things; see the health query section above. On opengov_background_queue_jobs it is where a background job stands: waiting, not_due_yet, running — cardinality 3, fixed. That second set is a constant in the code, never a value read from the database, so nothing in the queue can mint a series.
  • blocks — what a person cannot do while a part is broken: cannot_submit, cannot_review, none. Cardinality: 3, and it multiplies nothing: the health register fixes one value per part, so it rides along on that part’s own series rather than varying independently.
  • component — two unrelated value spaces, one per metric. On opengov_health_component_state it is a part of the deployment, one value per row of the health register (platform/health.py’s COMPONENT_REGISTER). On opengov_build_info it is which of the two programs this target is. Both are small fixed sets; neither is the other.
  • version, git_sha — on opengov_build_info only, alongside the component above; one series per target. git_sha is always the commit’s first twelve characters, whatever length the build handed in. Both processes and the web app’s /version read it from one resolver (src/opengov/platform/build_identity.py), so a consistent deployment can never look like two builds — counting count(count by (git_sha) (opengov_build_info)) returns 1 during steady state and 2 only while an upgrade is genuinely half-applied.

No label on this platform grows with the number of applicants, applications, agencies, or requests served, and none can be grown by anyone sending a request. Every bound above is fixed in code. Two move at all, and neither at runtime by a stranger’s doing: route moves when a release declares a new route, and connector and role move when an administrator adds an outside register or a published procedure adds an officer step — each capped in code, with everything past the cap folded into a single other, so the ceiling holds however many are added.


Named gaps — what this platform deliberately does not measure yet

Recording these here so they are found in one place instead of rediscovered as a surprise later (F8 of docs/audits/2026-08-11-observability-review.md). The section is rewritten each time one of its gaps closes, never quietly deleted — a reader has to be able to see which of yesterday’s absences are still absent. Three rounds of closures have happened, and what each one left behind is named below rather than dropped.

Closed since this section was first written. All four traffic signals now exist. Request rate, failing fraction and latency arrived first (opengov_http_requests_total, opengov_http_request_duration_seconds, per route shape, for the web app). Saturation, called out here as the missing fourth and specifically as the connection pool, arrived second: each process now publishes how many database connections it has handed out, how many sit idle, and the two configured limits (opengov_db_pool_*), which is exactly the thing this platform exhausts first. The background job queue — depth by live state and the age of the oldest job still waiting — is published too, so “is the worker keeping up?” no longer needs a database session. And how many separate accounts actually used the service over the last day, week and month is published (eapproval_distinct_applicants), which no counter could answer: adding up submissions counts one person filing ten times as ten people.

Closed in the third round, and what each one left behind. Two of the gaps above have gone; neither closed completely, and the remainder is stated here rather than allowed to disappear with the headline.

Timing a step inside an application’s life is now partly answered from two sides. eapproval_step_duration_seconds times one visit to one step, so “are the human steps or the bot steps slow?” no longer needs a database, and eapproval_work_queue_oldest_filing_age_seconds says how stale each desk’s worst case is right now. What is still missing is the pairing of the two: how long a filing spent at one named desk. The duration cannot carry the step as a label — step ids are agency-authored and unbounded, and the capping that makes them safe on a gauge cannot be applied to a histogram — and the age is measured from the filing’s arrival at the agency rather than at the desk, because nothing records the second. Answering “how long does Legal Review take” by name would need a stored arrival stamp per step, which is a schema change, not a measurement change. Nor is the applicant’s own correction round separated from the officer’s working time.

Whether background work is succeeding is now answered, and by counting rather than by querying: opengov_background_jobs_finished_total records each job as it ends, separating work that will be retried from work nobody will ever retry. The rejected approach is worth keeping on the record, because it will look attractive again — grouping the job runner’s own table by state, where nothing ever deletes a finished row, was measured at six to eight seconds against four million rows, a full table scan, slowest exactly during the incident it exists to show, and it would need an index on a table this platform does not own. What is still missing is the one ending the counter cannot see: a job whose task no longer exists in the running code fails before any middleware runs, so nothing counts it. The deployment’s own health check does not catch it either — the worker goes on sending its heartbeat while every job it picks up dies. The unbounded growth of that job table also remains its own separate problem.

What is still missing:

  • Whether the money actually arrived. The payment measurements say how many fees the platform stopped trying to confirm, how many an administrator cancelled, and how many are parked for a person. None of them says a payment was lost or received: this platform only ever knows whether it managed to ask the provider. Whose books hold the money is the provider’s answer.
  • Accounts, not people. eapproval_distinct_applicants counts separate accounts. One person holding two accounts counts twice, and an officer filing on somebody’s behalf files under whichever identity the filing carries. There is no measurement of distinct people, and there is deliberately no plan for one — it would need an identity label, which is exactly the kind of label this contract forbids.
  • Checks against an outside register are not broken down per operation. Outcome, reason and time on the wire are published per register (smartlink_external_check*); which operation within that register was called is not. Operations are agency-authored per register, so pairing them would multiply one open set by another. The per-operation view already exists as an administrator’s screen, backed by the audit trail.
  • notification_dispatch_duration_seconds — no histogram exists for per-attempt dispatch latency. A dashboard panel querying it was removed (it charted a metric nothing ever emitted).
  • Thread-projection repair count — the metric this platform used to export for the notifications-inbox thread-repair job was deleted. The repair itself exists only as a Postgres stored procedure with no Python caller, so the counter could never move; wiring the metric would mean writing a caller for a repair job that doesn’t exist, which is separate work.
  • No prober-facing feedback channel. Rate-limit rejections, IPN token rejections, and inbound-provider faults are all counted, but nothing here turns a sustained rate into an alert by itself — that is a country’s own monitoring’s job, built on top of this contract.

Grafana (optional — no Grafana ships with this platform)

ops/dashboards/phase2d-notifications.json is committed as an importable artifact, not a running service. It expects two Grafana-local datasource UIDs a country creates itself when it imports the dashboard:

  • prometheus — a Prometheus datasource pointed at both scrape targets above.
  • opengov-pg — a direct Postgres datasource (one panel reads notification_consent_events directly — this platform does not proxy every number through Prometheus).

Two independent dropdowns at the top of the page select a deployment, because the dashboard mixes label spaces: $deployment (from notification_dlq_depth’s deployment label) is a short code like tst-dep; $deployment_id (from notifications_health_refresh_lag_seconds’s deployment_id label) is a UUID. Picking one specific value in the wrong dropdown matches nothing — only All (the default) papers over the mismatch. Panel 4 (DLQ depth) filters on $deployment; panel 7 (health refresh lag) filters on $deployment_id.

Both dropdowns must be filled from a gauge, never from a counter, and this is a fixed bug rather than a style note. $deployment used to read notification_dispatch_attempted_total, which gains its first series only once a message has actually been dispatched. On a freshly installed country — and on the sandbox — nothing had been dispatched, so the dropdown was permanently empty and every panel filtering on it matched nothing. The page looked broken, and read as “this deployment is doing nothing” rather than the true “nothing has been sent yet”. The dead-letter depth gauge carries the same deployment label and is written on every dispatch pass whether or not anything was sent, so the dropdown is populated from first boot. tests/platform/test_dashboard_artifact.py now refuses any dropdown built on a counter or a histogram.