Skip to Content
JobWzrd Docs

Metrics and alerts

Superseded for scope. Alerts and dashboards now live in docs/architecture/OBSERVABILITY-ALERTS-RUNBOOKS.md (whole app + delivery mechanism).

No threshold in this document is a measured production value. They are proposed initial settings, labelled: [est] estimate, [measured-local] seen in local runs (recorded in QUEUE-CONCURRENCY-AND-THROUGHPUT.md), [unproven] needs a staging measurement before it can be trusted. Alerts must be re-tuned after staging.

1. Metric set (by subsystem)

API

MetricTypeSourceWhy
http_requests_total{route,method,status}counterlog-derived counter / Analytics Enginerate + error ratio
http_request_duration_ms{route}histogram (p50/p95/p99)Analytics Enginelatency SLO
auth_rejections_total{reason}counterlog eventsecurity + UX
cap_refusals_total{kind}countercap.reacheddemand vs allowance

Queues

MetricTypeSourceWhy
queue_depth{queue}gaugeQueues analyticsbacklog
oldest_message_age_s{queue}gaugeQueues analyticsprimary saturation signal
retries_total{queue}counterlog eventsystemic failure
dlq_depth{queue}gaugeQueues analyticssilent failures
consumer_invocations{queue}counterQueues analyticsactual concurrency

Scrapers

MetricTypeSource
scrape_requests_total{service,source}counterbackend log + scraper log
scrape_duration_ms{service,source}histogramscrape.dispatch.completed
scrape_outcome_total{service,source,outcome}counterdispatch events
scrape_http_status_total{service,status}counterdispatch events
scrape_empty_total{source}counteroutcome=empty — an empty board is a fact, not an error
scrape_uncertain_total{source}counteruncertain dispatch — must be zero in steady state
scraper_quota_refusals_total{service}counter402 responses
gateway_exit_readygaugegateway /health scrape by cron

D1

MetricTypeSource
d1_rows_written_totalcounterdb.batch.committed
d1_batch_duration_mshistogramsame
d1_batch_failures_total{err_code}counterdb.batch.failed
d1_slow_queries_totalcounterdb.query.slow
db_size_bytesgaugewrangler d1 info daily cron
retention_rows_deleted{kind}counterretention.run

AI / Gmail / R2

ai_calls_total{outcome}, ai_latency_ms, ai_tokens_total, ai_rate_limited_total, gmail_token_refresh_total{outcome}, gmail_send_outcome_total{outcome}, r2_ops_total{op,outcome}, r2_orphans_total.

2. Alerts

IDAlertSevCondition (proposed)WindowTargetRunbook
AL-01Search stuck runningS1searches.status='running' older than lease (10 min) > 0 rows5 minon-callRB-03
AL-02DLQ non-emptyS1dlq_depth > 0immediateon-callRB-05
AL-03Queue backlog ageingS1oldest_message_age_s > 9005 minon-callRB-02
AL-04API 5xx ratioS15xx / total > 5 %5 minon-callRB-12
AL-05Scrape uncertainS1scrape_uncertain_total increaseimmediateon-callRB-06
AL-06All sources failingS2scrape_outcome{outcome=failed} > 50 %15 minon-callRB-04
AL-07Gateway degradedS2gateway_exit_ready == 02 minon-callRB-07
AL-08D1 batch failuresS2d1_batch_failures_total > 05 minon-callRB-11
AL-09Scraper quota refusalsS2scraper_quota_refusals_total > 015 minownerRB-09
AL-10Retention sweep absentS2no retention.run for 2 expected intervals1 hon-callRB-17
AL-11Logpush gapS2partition completeness check failsdailyon-callRB-18
AL-12Crown dependency missingS2CONFIG_* 503 count > 05 minon-callRB-08
AL-13Auth rejection spikeS3auth_rejections_total > 10× baseline15 minsecurityRB-10
AL-14Empty-board ratio anomalyS3one source empty share > 80 % and failed == 01 hownerRB-07
AL-15R2 orphans detectedS3r2_orphans_total > 0dailyownerRB-13

Note on AL-14: an empty board and a broken parser both produce zero rows; only the pairing with failed == 0 + history distinguishes them, and that requires per-source history that does not exist yet (see FAILURE-MODE-REGISTER.md FM-12).

3. Dashboards (minimum)

  1. Search funnel: created → queued → claimed → settled, by status, p95 duration.
  2. Source matrix: rows = source_id, columns = ok/empty/failed/held, plus p95 latency.
  3. Queue health: depth, age, retries, DLQ, invocation count.
  4. D1 write health: rows/min, batch p95, failures, db size vs retention.
  5. Egress: gateway ready exits, 407 rate, per-exit served counts.

4. What cannot be alerted on today

Anything derived from logs, because there are 8 log lines. AL-01 (needs a stuck-search query, not a log), AL-03, AL-06, AL-08, AL-10, AL-12, AL-14 are unimplementable until the event catalogue is instrumented. This is the honest dependency: metrics follow logging, not the reverse.

On this page