Add Grafana alert on the sync_quarantine Loki stream (Reptide silent sync drops) #172
Labels
No labels
bug
enhancement
in-progress
needs-info
needs-triage
p0
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/nixos#172
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The Reptide app (
Cloonar/fit) now emits a telemetry event to Loki whenever the PowerSync connector drops a permanently-rejected upload op — a row the server rejects on every retry (FK / unique / RLS), quarantined so one bad write can't wedge the whole offline-sync queue. See fit PR Cloonar/fit#379 and ADRdocs/adr/0048-connector-referential-upload-ordering.md.A quarantine drop unblocks the user's sync but silently loses that one write. In steady state it should be ~zero; a nonzero / rising rate means either a genuine data condition or a new bug systematically dropping rows. The quarantine is a circuit breaker — this issue is its gauge: a Grafana alert on the drop rate so a spike is team-visible instead of silent.
Telemetry contract (already shipping from fit)
Client events reach Loki via the
log-eventedge function. A quarantine event is a Loki stream with these labels:appreptidecategorysync_quarantinelevelwarnenvproduction(fromLOKI_ENV)platformios/android/ …version,build,git_commitThe JSON log line carries
message(human summary),runtimeType = "sync_quarantine", andextra = { table, op, sqlstate, row_id }— the dropped row's coordinates (e.g.table="template_sets", op="put", sqlstate="42501").Ask
Add a provisioned Grafana alert rule (on
web-arm) that fires when thesync_quarantinedrop rate over a window exceeds a threshold.Stream selector:
{app="reptide", category="sync_quarantine"}Suggested query (Loki datasource
loki-datasource-uid):Suggested starting threshold (tunable): warning if the 15m count
>= 3withfor = "10m"— i.e. sustained drops, not a one-off. Consider splitting by env/platform (sum by (env) (...)). A single isolated drop happens occasionally; a sustained or spiking rate is the real signal.Implementation pointers (mirror the existing pattern)
Alerts live under
hosts/web-arm/modules/grafana/alerting/<category>/: each rule is agrafanaAlertRuleDefinitionslist, aggregated by adefault.nixinto aservices.grafana.provision.alerting.rules.settings.groupsgroup, and imported inhosts/web-arm/modules/grafana/default.nix(imports, ~lines 30–34).alerting/app/sync_quarantine.nix(a newapp/reptidecategory folder, or fold intoservice/), plus itsdefault.nix, and wire it intografana/default.niximports.vm-datasource-uid). This would be the first Loki-datasource alert. UsedatasourceUid = "loki-datasource-uid"(seegrafana/datasources/loki.nix) withqueryType = "range", then the samereduce(last) →math($X > threshold) expression chain asalerting/system/ram_usage.nix.Routing
No contact-point change required: the root notification policy routes all alerts to
cp_dominik_normal(Pushover, priority 1). If sync data-loss should page louder, add a route matching this rule'salertnametocp_dominik_emergency, mirroring the existingHostDownroute ingrafana/default.nix.Acceptance criteria
sync_quarantinestream, deployed onweb-arm.cp_dominik_normalis fine).sync_quarantinedown bytable/sqlstate(parsed from the log line'sextra) for triage.