Skip to content

Keep health checks out of the API error and latency alerts #710

Done

Description

@HMarzban

Problem

Health probes and metric scrapes make up 92.8 % of REST requests. In the 7 days to 2026-11-10 00:00Z, they made 441,735 of 476,161 REST requests (Measured). The REST error and latency alerts therefore measure the probes, not the API.

First read, 7 days to 2026-11-07, from http_requests_total{job="rest-api"}. The 2026-11-10 totals supersede it. It stays for the per-route split:

Route Requests
/health/live 241,782
/health/database 119,457
/metrics 40,295
/health 20,173
/health/supabase 20,149
/api/documents/:docName (the busiest real route) 16,335

In that first read, probes and scrapes totalled 441,856 of about 467,000 requests.

  • "HTTP 5xx ratio per service (>5%)" (slo-http-5xx-ratio in scripts/observability/grafana/provisioning/alerting/rules-app-slo.yml) divides by every request. If every real API request failed, the ratio would reach only about 5%.
  • "App request p95 latency (>1s)" (slo-latency-p95-app, same file) reads the same mix. The 1-day p95 was 0.17 s, mostly probe time.
  • "Edge p95 latency" (slo-latency-p95-edge) pools every HTTP service behind Traefik. GlitchTip (127,550) and webapp (147,970) requests outweigh rest-api (60,185) in about 345,000. Cut MCP write time on large pads and stop its four false alerts #726 Decision 5 splits out only /api/mcp.
  • The first 5xx on a route after a deploy is not counted. http_requests_total has no seeded 5xx series, so increase() misses its first increment. Prometheus counted 3 /health/database 503 answers where Loki logged 5 in the same week.
  • The 5xx rule comment is wrong. It says the WebSocket process has no HTTP timer. apps/hocuspocus.server/src/hocuspocus.server.ts added one on 2026-09-05.

A real slowdown went unpaged. On 2026-11-01, REST logged 5 /health/database checks that timed out after 2000 ms, between 17:20 and 22:25 UTC. At 22:25 the webapp failed page loads with DocumentFetchError, and Traefik answered 5 webapp 500s. No alert fired.

Filtering out the probes has side effects. The Step 0 backtest (Measured) reads the latency side on W7, 2026-11-03 00:00Z to 2026-11-10 00:00Z:

  • The probe filter alone fires more: 54 shape (b) minutes and 28 Grafana Firing minutes, against 17 and 16 today. Its one firing, 28 minutes, falls in the 2026-11-09 MCP session. /api/mcp sits at 2.19 s p95. Without /api/mcp, the rule reads 26 shape (b) minutes and 0 Grafana firings. Real traffic is about 3.2 requests a minute.
  • The review backtest read 81 and 53 minutes (review read, other window). The Measured W7 values replace them.
  • With the probes gone, the 5xx ratio runs on about 16 requests per 5 minutes. One error is about 6 %, above the 5 % line.
  • increase() extrapolates: on 2026-11-01 it read 1.034 and then 2.069. A gt 1.5 database-health rule with for: 0s fires at 18:46Z (18:51Z with for: 5m). That is 3 h 39 min before the 22:25Z failures (Measured).

Step 0 is posted, so the 2026-11-01 data may now leave Prometheus.

Benchmark

Field Value
Metric (a) Probe and scrape share of the 5xx and latency denominators, %. (b) Minutes Firing, slo-latency-p95-app, 7-day backtest, by Grafana replay count. (c) Breach minutes, guarded 5xx ratio, 7-day backtest. (d) Database-health rule fire time on 2026-11-01. (e) Fire test (step 6): cases that reach the expected state, and time to Firing. (f) hocuspocus code-0 requests counted as errors in AP 3, 5, 33 and 34, 7 days. (g) Panels in app-performance.json with a wrong value, count
Before Step 0, Measured. (a) 441,735 of 476,161 (92.8 %), 7 days to 2026-11-10 00:00Z. (b) W7 Grafana count: 16 Firing minutes today (shape (b) 17). The probe filter with no guard: 28 (shape (b) 54). The new expression: 0 (shape (b) 26). Review read, other window: 81 and 53. (c) 0, but no real 5xx happened, so the guard is untested. (d) no alert. (e) not tested. (f) 5,111.3 of 5,155.3. (g) 10 (AP 3, 5, 6, 7, 24, 25, 32, 33, 34, 45)
After 3 days to 2026-11-16 14:00Z (Measured): (a) 0 %. (b) 0. (c) 0, guard untested in production; the step 6 promtool case covers it. (f) 0. (g) 0. (e) 7 of 7 (Measured). The 7-day after of (a), (b) and (f) is owed (step 9)
Condition Production Prometheus, rules evaluated each minute. Backtest windows: 2026-11-01 17:00Z to 23:00Z, and the 7 days to 2026-11-10 00:00Z. Fire test with promtool test rules on synthetic series, no production access (step 6)
How to run (a) sum by (route) (increase(http_requests_total{job="rest-api"}[7d])) at 2026-11-10 00:00Z. (b) count_over_time((min_over_time(<p95 expr>[10m:1m]) > 1)[7d:1m]) for the old and new expressions. (c), (d) the same subquery shape for the 5xx and database-health expressions. (e) Step 6. (f), (g) panel queries in Grafana after the deploy
Pass rule (a) 0 %. (b) 0 outside known incidents, by the Grafana replay count; shape (b) is context only. (c) 0. (d) fires at 18:46Z on 2026-11-01 (for: 0s). (e) every step 6 case reaches its expected state; post the time to Firing per case. (f) 0. (g) 0. Revert rule: if a new rule fires outside a real incident in the first 7 days, run the Rollback
Guard Rule count: the count before this change + 2. If this ships with other rule changes, the #753 want for that deploy is the check. The #753 Verify step reports got = want and error_health=0. Depends on #753
Owner Agent in the repo: rule and panel edits, step 6 fire test. Maintainer: Step 0 (done), production reads, deploy after #753
Claim "Our API error alert now reads only real API traffic. Health probes made 92.8 % of its input before and 0 % now."

What to do

  1. Maintainer, read-only. Done 2026-11-11 (Measured). Run the old and new 5xx, latency, MCP latency and database-health expressions over 2026-11-01 17:00Z to 23:00Z. Run them again over the 7 days to 2026-11-10 00:00Z. Post the raw values and the first fire time. Step 0 needs no deploy, so it runs now.

  2. Agent in the repo. 5xx rule (slo-http-5xx-ratio): add route!~"/health.*|/metrics" to the numerator and the denominator. Add a volume guard: and on() (sum(increase(http_requests_total{job="rest-api",route!~"/health.*|/metrics"}[10m])) >= 20). Fix the rule comment: hocuspocus.server.ts has had an HTTP timer since 2026-09-05.

  3. Agent in the repo. Latency rule (slo-latency-p95-app): use route!~"/health.*|/metrics|/api/mcp". No volume guard and no threshold change: the Step 0 backtest reads 0 Grafana firings at 1 s in W7. Keep health checks out of the API error and latency alerts #710 writes the final App p95 selector. Cut MCP write time on large pads and stop its four false alerts #726 owns only the MCP Traefik router.

  4. Agent in the repo. New MCP latency rule, so /api/mcp is not left out of all alerting. uid: slo-latency-p95-mcp, severity warning, noDataState: OK. A: histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket{job="rest-api",route="/api/mcp"}[5m]))). Bar 5 s (ruling 2026-11-11, comment). At 5 s it fires once in W7, on the 2026-11-09 MCP session, which counts as a real incident. Cut MCP write time on large pads and stop its four false alerts #726 only rechecks the bar after its after-session.

  5. Agent in the repo. New database-health rule. A = sum(increase(http_requests_total{job="rest-api",route="/health/database",status="503"}[15m])), C = gt 1.5, for: 0s, severity warning, noDataState: OK. Seed only http_requests_total{method="GET",route="/health/database",status="503"} at 0 at REST start. Confirm the method label that the middleware writes.

  6. Agent in the repo. Edge rule (slo-latency-p95-edge): histogram_quantile(0.95, sum by (le, service) (rate(traefik_service_request_duration_seconds_bucket{service=~"rest-api.*|webapp.*",service!~".*mcp.*"}[5m]))). The selector must leave out the Cut MCP write time on large pads and stop its four false alerts #726 MCP service. Cut MCP write time on large pads and stop its four false alerts #726 confirms that its Traefik service matches .*mcp.*; that check is not part of this issue.

  7. Agent in the repo, fire test. The repo has no local Prometheus and Grafana stack (the Makefile runs observability on the server only). So test the expressions with promtool test rules (it ships in the Prometheus image). Write a temporary rule file with the same expressions, and synthetic input series. It needs no production access. Cases:

    • Database health: two /health/database 503 answers within 15 min give Firing. One gives Normal.
    • 5xx guard: 20 or more non-probe requests in 10 min, with over 5 % 5xx, give Firing. Fewer than 20 requests give Normal.
    • Record the time to Firing per case.
    • If the maintainer wants a Grafana-side test instead, first write the full local recipe here. Name the compose command, dummy env, scrape target, request loop and the container to stop.
  8. Agent in the repo. Fix the panels in app-performance.json, in the same change as the rules:

    Panel Problem Fix
    AP 7, and the hocuspocus rows of AP 6, 32 and 34 For a WebSocket, Traefik's duration is the connection's lifetime, so p95 sits at the 5 s top bucket Leave the hocuspocus router out of latency panels
    AP 3, 5, 33 and 34 They count code 0, a normal WebSocket close, as an error. hocuspocus code 0 was 5,111.3 of 5,155.3 requests in 7 days Leave the hocuspocus router out of the code-0 term. Keep code 0 for HTTP services, where it means no response (so AP 14 and 16 stay)
    AP 24 and 25 No datname filter, so they add up every database on the cluster Filter on the collab database datname. The maintainer reads it from pg_database_size_bytes after the 2026-11-11 London move
    AP 45 "GC Rate by Job" Always empty under Bun Delete it
  9. Maintainer, observability deploy, after Fail the observability deploy when Grafana or its provisioned rules do not load #753. Commit through the commit-review skill with a (build): observability subject and push.

  10. Agent, read-only, on or after 2026-11-19. The one task left. Steps 0 to 8 are done: rules live since 2026-11-12, panels since 2026-11-16 13:43Z (288d4d260). Read (a), (b) and (f) over 7 days by the Step 0 method. Post them, log them in v2.3.7 benchmark ledger: every quotable claim, with n, range, condition and source #796, then close. Do not re-read (c): no real 5xx can test it, and the step 6 promtool case covers the guard.

The event-loop rule moves to #729, because it needs a different metric.

Decisions

Decisions 1 and 2 were ruled as shipped on 2026-11-16 (ruling).

  1. Should a failed /health/database check alert on its own? Recommended: yes, at warning severity, on the step 4 expression (gt 1.5 over 15 minutes). It was the only early sign on 2026-11-01.
  2. Should we seed the 5xx series? Recommended: seed only http_requests_total{method="GET",route="/health/database",status="503"} at 0 at REST start. Leave every other route unseeded. Prometheus counted 3 of 5 logged 503s, so the first 503 after each deploy is lost without the seed. Seeding every route would need a list of routes to keep in step.
  3. MCP latency alert? Ruled 2026-11-11 (comment): this issue ships slo-latency-p95-mcp at a 5 s bar. Cut MCP write time on large pads and stop its four false alerts #726 owns only the MCP Traefik router and the MCP edge rule.

Acceptance

  • Step 0 values and the first fire time are posted (Measured).
  • Both rules leave out /health* and /metrics. The 5xx rule has the volume guard.
  • In Grafana Explore, the new 5xx expression reads 0 while only probes run.
  • The latency rule backtest reads 0 Grafana firings outside known incidents (W7, Measured).
  • /api/mcp latency has its own rule, slo-latency-p95-mcp, at a 5 s bar.
  • Every step 6 promtool case passes, for the database-health rule and the 5xx guard.
  • Each panel in the step 7 table shows the corrected value in Grafana.
  • Grafana holds the count before this change + 2 rules.
  • Step 9: the 7-day (a), (b) and (f) reads are posted and logged in v2.3.7 benchmark ledger: every quotable claim, with n, range, condition and source #796.

Rollback

Revert the commit and run the observability deploy.

Found in the production review of 2026-11-07.

Activity

  1. added this to the v2.3.6 milestone on Nov 11, 2026
  2. HMarzban commented on Nov 11, 2026

    @HMarzban
    CollaboratorAuthor

    Update, 2026-11-10: one more rule, and panels with the same problem

    v2.3.6 takes this issue. In the 7 days to 2026-11-10, probes and scrapes made 441,800 of 474,600 REST requests (93 %).

    One more rule

    • "Edge p95 latency" (slo-latency-p95-edge) pools every HTTP service behind Traefik. GlitchTip (127,550) and webapp (147,970) requests outweigh rest-api (60,185) in about 345,000. Cut MCP write time on large pads and stop its four false alerts #726 Decision 5 splits out only /api/mcp.
    • The comment on the 5xx rule says the WebSocket process has no HTTP timer. apps/hocuspocus.server/src/hocuspocus.server.ts:652 added one on 2026-09-05. Fix the comment in the same change.
    • The event-loop rule moves to the new stall issue, because it needs a different metric.

    Panels in app-performance.json that show the wrong thing

    Panel Problem Fix
    AP 7, and the hocuspocus rows of AP 6, 32 and 34 For a WebSocket, Traefik's duration is the connection's lifetime, so p95 sits at the 5 s top bucket Leave the hocuspocus router out of latency panels
    AP 3, 5, 33 and 34 They count code 0, a normal WebSocket close, as an error. hocuspocus code 0 was 5,111.3 of 5,155.3 requests in 7 days Drop |0 from code=~"5..|0"
    AP 24 and 25 No datname filter, so they add up all 8 databases on the cluster Filter on the collab database
    AP 45 "GC Rate by Job" Always empty under Bun Delete it

    Proposed added step

    1. Fix the panels in the table, in the same change as the rules.

    Added acceptance item: each panel in the table shows the corrected value in Grafana.

  3. HMarzban commented on Nov 11, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-11. Step 0 backtest of the old and new rule expressions, read-only on production Prometheus.

    How this was read

    • Windows (UTC): W1 is 2026-11-01 17:00Z to 23:00Z (n = 361 evaluations). W7 is 2026-11-03 00:00Z to 2026-11-10 00:00Z (n = 10,080). Each range query starts 10 minutes early, so for: 10m can build up.
    • Step: 1 min, the Grafana evaluation interval.
    • Two counts, because they disagree on quiet traffic:
      • Shape (b) is the issue's query: count_over_time((min_over_time(<expr>[10m:1m]) > <bar>)[7d:1m]), instant at 2026-11-10 00:00Z. min_over_time skips NaN samples. So a few slow requests with empty minutes between them still count.
      • Grafana count replays the rule. A breach is a value over the bar. NaN or no data is not a breach, and it resets for. Firing starts at the 11th breach in a row (for: 10m). A firing is one change from Normal to Firing.
    • Grafana 13 treats NaN this way. The threshold gt is a plain f > bar test, so NaN gives 0, and 0 is Normal (Grafana source, pkg/expr/threshold.go).
    • A NaN p95 means no request in the 5-minute window. On the filtered latency expression, 3,854 of 10,091 W7 samples are NaN.

    Expressions

    # 5xx, old
    sum by (job) (rate(http_requests_total{job="rest-api",status=~"5.."}[5m])) / sum by (job) (rate(http_requests_total{job="rest-api"}[5m]))
    # 5xx, new (step 1), bar 0.05, for 10m
    (sum by (job) (rate(http_requests_total{job="rest-api",status=~"5..",route!~"/health.*|/metrics"}[5m])) / sum by (job) (rate(http_requests_total{job="rest-api",route!~"/health.*|/metrics"}[5m]))) and on() (sum(increase(http_requests_total{job="rest-api",route!~"/health.*|/metrics"}[10m])) >= 20)
    # App latency, old; bar 1 s, for 10m
    histogram_quantile(0.95, sum by (le, job) (rate(http_request_duration_seconds_bucket{job="rest-api"}[5m])))
    # App latency, probe filter only
    histogram_quantile(0.95, sum by (le, job) (rate(http_request_duration_seconds_bucket{job="rest-api",route!~"/health.*|/metrics"}[5m])))
    # App latency, new (step 2)
    histogram_quantile(0.95, sum by (le, job) (rate(http_request_duration_seconds_bucket{job="rest-api",route!~"/health.*|/metrics|/api/mcp"}[5m])))
    # MCP latency (step 3); for 10m assumed
    histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket{job="rest-api",route="/api/mcp"}[5m])))
    # Database health (step 4), bar 1.5
    sum(increase(http_requests_total{job="rest-api",route="/health/database",status="503"}[15m]))
    

    (a) Probe and scrape share, 7 days to 2026-11-10 00:00Z

    sum by (route) (increase(http_requests_total{job="rest-api"}[7d])): /health* and /metrics made 441,735 of 476,161 requests (92.8 %). /api/mcp made 2,294.

    W1: 2026-11-01, 17:00Z to 23:00Z

    Rule Peak value Breach minutes Firings (Grafana count) First fire
    5xx, old 0.5 % 0 0 none
    5xx, new no data 0 0 none
    App latency, old 28.14 s 5 (22:26Z to 22:30Z) 0 none
    App latency, new 28.71 s 5 (22:26Z to 22:30Z) 0 none
    MCP latency 0.0975 s 0 0 none
    Database health, for: 0s 2.069 10 (18:46Z to 18:55Z) 1 18:46Z
    Database health, for: 5m 2.069 10 1 18:51Z
    • Database health read 1.034 from 18:41Z, 2.069 from 18:46Z, 1.034 from 18:56Z, and 0 from 19:00Z. It rose to 1.034 again from 22:26Z to 22:40Z, below the bar.
    • The latency spike lasted 5 minutes, so no for: 10m rule fired on it.
    • No 5xx series outside /health* exists in the last 15 days. So the new 5xx expression has no data, and Grafana reads it as OK.

    W7: 2026-11-03 00:00Z to 2026-11-10 00:00Z

    Rule Shape (b) minutes Grafana Firing minutes Firings First fire
    5xx, old 0 0 0 none
    5xx, new (guarded) 0 0 0 none
    App latency, old, bar 1 s 17 16 1 2026-11-09 18:34Z
    App latency, probe filter, bar 1 s 54 28 1 2026-11-09 18:25Z
    App latency, new, bar 1 s 26 0 0 none
    App latency, new, bar 1.5 s 24 0 0 none
    App latency, new, bar 2 s 20 0 0 none
    App latency, new, bar 3 s 0 0 0 none
    App latency, new, bar 1 s, guard of 20 requests per 10 min 71 0 0 none
    MCP latency, bar 2 s 33 23 1 2026-11-09 18:30Z
    MCP latency, bar 3 s 32 22 1 2026-11-09 18:31Z
    MCP latency, bar 5 s 25 15 1 2026-11-09 18:38Z
    MCP latency, bar 10 s 0 0 0 none
    Database health, bar 1.5 0 0 0 none

    Shape (b) minutes by hour (UTC):

    Hour Probe filter New
    2026-11-05 03:00 5 5
    2026-11-05 04:00 1 1
    2026-11-06 00:00 13 13
    2026-11-07 20:00 2 2
    2026-11-07 23:00 4 4
    2026-11-08 14:00 0 1
    2026-11-09 18:00 29 0
    • The old rule's 17 minutes and every MCP minute fall in the 2026-11-09 MCP session. MCP p95 was over 1 s at times from 18:15Z to 20:23Z. It peaked at 9.42 s.
    • The 26 minutes for the new expression fall in quiet night hours. They come from a few slow requests between empty minutes. Grafana would not fire on them.
    • The guard makes shape (b) worse, 71 minutes, because it removes more samples. Shape (b) cannot model a guard, so read the Grafana count for guarded rules.
    • The 7-day review backtest read 81 (probe filter) and 53 (new). The same query on the issue's W7 reads 54 and 26. The review window was probably different.

    What this means for the pass rule

    • (a) Before: 92.8 % of the denominators are probes and scrapes. After should be 0 %.
    • (b) The new App latency rule at 1 s fires 0 times in W7 by Grafana count. Shape (b) reads 26 minutes, all from quiet-hour gaps, and it reaches 0 at a 3 s bar. The probe filter alone fires once, on the 2026-11-09 MCP session, so excluding /api/mcp is what makes this rule pass.
    • (c) The guarded 5xx ratio has 0 breach minutes. No real 5xx happened, so this does not test the guard. The local fire test or Grafana Explore must show it.
    • (d) The database-health rule fires at 18:46Z on 2026-11-01 with for: 0s (18:51Z with for: 5m). That is 3 h 39 min before the 22:25Z failures. Pass.
    • MCP bar: at 2 to 5 s, the rule fires once in W7, on the 2026-11-09 MCP session. At 10 s it fires 0 times. If that session counts as a known incident, a 2 s bar meets "0 outside known incidents". Otherwise the bar must be 10 s.
    • Raw responses: 710-*.json beside this file.
  4. HMarzban commented on Nov 11, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-11-11

    • Decision 3. This issue ships slo-latency-p95-mcp. The rule count becomes before + 2. Cut MCP write time on large pads and stop its four false alerts #726 owns only the MCP Traefik router and the MCP edge rule, and it rechecks the bar after its after-session.
    • MCP latency bar: 5 s. In the Step 0 backtest (comment of 2026-11-11), 5 s fires once in 7 days, on the 2026-11-09 MCP session. That session counts as a real incident (MCP p95 peaked at 9.42 s). A 10 s bar would have missed it.
  5. HMarzban commented on Nov 12, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-12: production after the observability deploy. Run 43224277563 ((build): observability, f61647754). Steps 1 to 8 passed, including "Deploy stack" at 13:08:16Z. A newer push cancelled the last step, Verify, during its wait, so its checks were read by hand, read-only, at about 13:12Z.

    • Live Grafana holds 60 rules: 55 before, plus slo-latency-p95-mcp and dep-rest-db-health-503 from this issue, plus the three Alert before the shared collab Postgres cluster fills its disk #727 rules. 0 rules are in error health.
    • The REST /health/database 503 seed ships with the (build): back front deploy (run 43224537614), so its series appears after that deploy.
  6. HMarzban commented on Nov 12, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-12: the 503 seed is live. After the (build): back front deploy (run 43224537614, 9f132692e, green at 13:18:36Z), Prometheus reads http_requests_total{job="rest-api",route="/health/database",status="503"} = 0 on both REST replicas. Before the deploy the series did not exist, so increase() missed the first 503 after each start. dep-rest-db-health-503 now counts it.

  7. HMarzban commented on Nov 14, 2026

    @HMarzban
    CollaboratorAuthor

    Moved to v2.3.7 at the v2.3.6 release audit. Rules are live, but the after values (a) to (g) and the promtool fire test are not posted.

  8. modified the milestones: v2.3.6, v2.3.7 on Nov 14, 2026
  9. HMarzban commented on Nov 16, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-16

    This covers steps 6 and 7, committed in 6a99bee10. Steps 1 to 5 were already in the repo (5dcc63ff4, 55e2d6af8) and live since 2026-11-12, so no rule changed.

    What changed

    • Step 4 check. The middleware writes method from c.req.method, which is GET. The seed uses method="GET", so the labels match.
    • Step 6, fire test. promtool test rules (prom/prometheus:v3.12.0) runs the expressions read from the live rule files on synthetic series. Every case reaches its expected state.
    • Step 7, panels. AP 6, 7, 32 and 34 (A, B) leave out hocuspocus. In AP 3, 5, 33 and 34 (D), only 5xx counts for hocuspocus. Code 0 still counts on rest-api and webapp. AP 14 and 16 are unchanged. AP 45 is deleted, and AP 44 now fills its row (w12 to w24; the issue names only the delete).
    • Step 7, AP 24 and 25. The commit, rollback and cache-hit terms now read datname="prod_docsplus". The datname was read from production pg_database_size_bytes on 2026-11-16: the exporter lists 8 databases on the shared cluster, and prod_docsplus is the collab database.

    Fire test (step 6)

    The eval interval is 1 min. Probes run at 124 req/min in the 5xx cases.

    Case Old 5xx expression New rule Time to Firing
    5xx: 3 ok + 1 error per min on a real route Normal Firing 10 min after the first 5xx
    5xx: 1 error per min, nothing else (10 per 10 min) Normal Normal —
    5xx: probes only, /health/database 503 every min Normal Normal —
    DB health: seeded, two 503s 5 min apart no rule Firing 0 min after the second 503
    DB health: seeded, one 503 no rule Normal —
    DB health: seeded, two 503s 19 min apart no rule Normal —
    DB health: not seeded, two 503s 5 min apart no rule Normal —

    The last row shows why the seed matters: without it, increase() reads about 1.1 for two 503s.

    Before and after

    Metric Before After Change n, range, condition, source
    (g) Panels with a wrong value 10 0 none left 73 panels, static selector check, HEAD file and working tree
    AP 24 commit rate, production, instant read 15.1000 tx/s (all 8 databases) 1.8926 tx/s (prod_docsplus) 87 % less n = 1 each, read-only through the Grafana data-source proxy, 2026-11-16
    (e) Fire-test cases at the expected state not tested 7 of 7 — promtool, synthetic series, 0 to 60 min
    AP 3 value on synthetic series at the (f) shares 0.845 % 0 % 100 % less promtool at 30m, series at the (f) 7-day shares
    AP 33 hocuspocus bar 99.15 % bar gone (no hocuspocus 5xx) — same run
    AP 6, 32, 34 hocuspocus p95 5 s not shown — same run
    Rules in the repo files 66 66 0 grep -c '^ - uid:'. HEAD then held 64; the 66 includes the 2 #749 rules (f47ea3bd9). This change adds 0

    (f) and (g) in production stay with the after reads below.

    Gates

    • bunx prettier --check app-performance.json: pass.
    • python3 -m json.tool (the CI step): pass.
    • promtool check rules and promtool test rules: pass.
    • All 88 dashboard expressions parse in promtool check rules: pass.
    • Grafana 13.1.0 load, --network none, dummy contact points: 73 panels, 66 of 66 rules. Pass.

    Left

    After the deploy

    Deployed with (build): observability (288d4d260, run 43878530215, 2026-11-16 13:43Z). Grafana now serves the app dashboard with 74 panels: AP 80 and AP 81 are present, AP 45 is gone. On 2026-11-16, AP 24's commit rate reads 1.8926 tx/s for prod_docsplus, against 15.1000 tx/s for the whole cluster before the filter.

  10. HMarzban commented on Nov 16, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-16: production after reads (a), (b), (c), (f), (g)

    Read-only, production Prometheus and Grafana through the data-source proxy, 2026-11-16. Window: the 3 days to 2026-11-16 14:00Z, after the rule deploy of 2026-11-12. The before used 7 days; this window is 3 days, so compare shares, not totals. The 7-day read follows on or after 2026-11-19 (Left).

    Metric Before (Step 0, 7 days to 2026-11-10) After (3 days to 2026-11-16 14:00Z) Pass rule
    (a) Probe and scrape share of the rule denominators 441,735 of 476,161 (92.8 %) 0 %: the rules read route!~"/health.*|/metrics". In the same window probes made 189,662.699 of 195,044.04 REST requests (97.2 %); the rules count the other 5,381.341 0 %: met
    (b) slo-latency-p95-app minutes Firing, Grafana state history 16 (shape (b) 17) 0. The rule went Pending 18 times and back to Normal 18 times, never Alerting (shape (b) 18, context only) 0: met
    (c) Breach minutes, guarded 5xx ratio 0 (guard untested) 0. No real 5xx happened on non-probe routes in the window, so the guard is still untested 0: met, untested
    (f) hocuspocus code-0 requests counted as errors in AP 3 5,111.3 of 5,155.3 (7 days) 0. Same 3 days through the old AP 3 expression: 954.11 of 967.112 errors were hocuspocus code 0; the new expression counts 13.002, none of them hocuspocus code 0 0: met
    (g) Panels in app-performance.json with a wrong value 10 0 (live since the 2026-11-16 13:43Z observability deploy; AP 24 and 25 read prod_docsplus) 0: met
    • (d), the 2026-11-01 fire time, is not re-read: that data has left Prometheus. The step 6 fire test covers the rule shape (7 of 7 cases).
    • Grafana alert annotations in the window: "App request p95 latency (>1s)" Pending 18, Normal 18; "HTTP 5xx ratio", the database-health rule and the MCP latency rule: none.
    • The revert rule (a new rule firing outside a real incident in the first 7 days) has not triggered.

    Left

  11. HMarzban commented on Nov 16, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-11-16

    Answered by the maintainer in the 2026-11-16 working session; posted by the agent.

    • Decisions 1 and 2: ruled as shipped on 2026-11-12 (database-health warning at gt 1.5 over 15 minutes; seed the GET /health/database 503 series at 0).
    • clamp_min(req/s, 1) on AP 3 and AP 14: keep as is.
  12. HMarzban commented on Nov 16, 2026

    @HMarzban
    CollaboratorAuthor

    Review, 2026-11-16 (maintainer approved).

  13. HMarzban commented on Nov 20, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-20: production 7-day after reads (a), (b), (c), (f)

    Step 9. Read-only, production Prometheus and the Grafana API, on 2026-11-20. Method: Step 0, unchanged.

    How this was read

    • Window (UTC): 2026-11-13 00:00Z to 2026-11-20 00:00Z (n = 10,080 evaluations at 1 min). It ends at 00:00Z, like the before.
    • The rules went live on 2026-11-12 at 13:08Z. The window starts after that, so every minute ran the new rules.
    • Host move inside the window. The host moved from Debian 11 to Debian 13 on 2026-11-18. Its reboots, about 07:17Z to 08:16Z, fall inside this window.
    • No 7-day window after the deploy can end before the move. So the 7-day totals pool both hosts.
    • Each total is also split, so no number hides the move:
      • Pre-move: 2026-11-13 00:00Z to 2026-11-18 07:00Z (127 h, n = 7,620).
      • Post-move: 2026-11-18 09:00Z to 2026-11-20 00:00Z (39 h, n = 2,340).
      • The 2 h between them (n = 120) are in the 7-day pool only.
    • Prometheus restarted at 08:10:39Z. Both REST replicas started at 08:16:19Z. up{job="rest-api"} has gaps between 07:56Z and 08:20Z.
    • (a): sum by (route) (increase(http_requests_total{job="rest-api"}[7d])), instant at 2026-11-20 00:00Z. The same query ran on each rule's own selector.
    • (b) and (c): the live rule expression, range query at a 1 min step. Grafana count: a value over the bar is a breach. NaN or no data is not a breach, and it resets for. Firing starts at the 11th breach in a row (for: 10m).
    • (b) and (c) were also read from Grafana state history, /api/annotations?type=alert over the same window.
    • (f): sum by (service, code) (increase(traefik_service_requests_total{service=~"hocuspocus.*|rest-api.*"}[7d])), then the old and new AP 3 selectors.
    • The live rules and the live docsplus-app-performance dashboard were read first. Both match the repo: the rules carry the probe filter, and AP 3, 5, 33 and 34 (D) do not count hocuspocus code 0.

    Before and after

    Metric Before (Step 0, 7 days to 2026-11-10) After (7 days to 2026-11-20 00:00Z) Change Pass rule
    (a) Probe and scrape share of the rule denominators 441,735 of 476,161 (92.8 %) 0 of 11,963.277 (0 %) in the 5xx rule. 0 of 10,156.424 (0 %) in the latency rule none left 0 %: met
    (b) slo-latency-p95-app minutes Firing, Grafana count 16 (shape (b) 17) 0 (shape (b) 38, context only) none 0: met
    (c) Breach minutes, guarded 5xx ratio 0 (guard untested) 3, from one real 500. 0 firings from 0, so no percent context only (ruled 2026-11-20): pass
    (f) hocuspocus code-0 requests counted as errors in AP 3, 5, 33 and 34 5,111.3 of 5,155.3 0. The old AP 3 expression would count 2,238.111 of its 2,256.112 errors (99.20 %) none left 0: met

    Split at the host move

    Metric Pre-move (127 h) Post-move (39 h) 7-day pool
    (a) Probes in all REST requests 334,539.997 of 343,820.529 (97.30 %) 102,709.947 of 105,324.550 (97.51 %) 441,453.106 of 453,416.383 (97.36 %)
    (b) Breach minutes, new latency rule, bar 1 s 139 39 178
    (b) Minutes Firing, Grafana count 0 0 0
    (b) Pending starts, Grafana state history 34 10 44
    (b) Shape (b) minutes 24 14 38
    (c) Breach minutes, guarded 5xx ratio 3 0 3
    (f) Old AP 3 errors, and the hocuspocus code-0 part 1,818.119, of which 1,801.118 412.088, of which 412.088 2,256.112, of which 2,238.111
    (f) New AP 3 errors 17.001 0 18.001

    The new AP 3 pool is 1 more than the two parts. One rest-api 503 at Traefik fell in the 2 h of the move.

    Notes

    • (a). The probe share of all REST requests rose, from 92.8 % to 97.36 %. Probes stayed level, but real traffic fell: 34,426 before, 11,963.277 now (65 % fewer). The rules read none of the probes.
    • (a). /api/mcp made 1,806.853 requests. The latency rule leaves them out. slo-latency-p95-mcp reads them.
    • (b). The rule went Pending 44 times and back to Normal 44 times. It never reached Alerting. The replay counts 43 Pending starts, because Grafana evaluates at :30 and the replay at :00.
    • (b). The longest breach run was 8 minutes, ending at 2026-11-13 15:04Z. Firing needs 11.
    • (b). The old expression, without the filter, has 0 breach minutes in this window. Its peak was 0.9902 s at 2026-11-16 13:04Z.
    • (c), what happened. One request on /api/plugins/hypermultimedia/:documentId took between 30 s and 60 s (its histogram bucket) and returned 500. It is the only non-probe 5xx in the window (increase 1.001).
    • (c). At 2026-11-13 06:21:30Z the rule read 0.054630 and went Pending. It went back to Normal at 06:25:30Z and never fired.
    • (c). That same request drove the new latency peak, 52.5 s at 06:24Z.
    • (c), the guard. This is the first real production case for the guard. Traffic was over 20 requests per 10 min, so the guard let the ratio through. for: 10m kept one error from paging.
    • (c), the pass rule. "0" assumed no real 5xx. One 500 gave 3 breach minutes and 0 firings. The 2026-11-16 review dropped (c) from step 9. The maintainer ruled on 2026-11-20 that (c) is context only, so this counts as a pass.
    • Revert rule. None of the four rules from this issue reached Alerting from 2026-11-12 13:00Z to 2026-11-20 00:00Z. That covers the first 7 days, so the revert rule did not trigger.
    • slo-latency-p95-mcp and the database-health rule had no state change in that time.

    Left

  14. HMarzban commented on Nov 24, 2026

    @HMarzban
    CollaboratorAuthor

    Closed, 2026-11-24

    Closing #710 now. No action needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions