FFFF ✨ quieter, more accurate alerts by abahmed · Pull Request #630 · abahmed/kwatch · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ checkout-api is crash-looping because a ConfigMap changed 4 minutes ago.

Why DB_HOST points to a host that doesn't resolve
Who deploy-bot, via Argo CD
Impact payments, cart
Impact service-b, cart
Next Roll back checkout-config
```

Expand Down Expand Up @@ -194,14 +194,14 @@ probe is never listed:
🟡 **kwatch summary** · prod-eu-1 — 1 problem

**Problems**
- Service **web** (**shop**) — failed to deploy its load balancer: FailedDeployModel ×5 in 15 min
- Service **service-a** (**shop**) — failed to deploy its load balancer: FailedDeployModel ×5 in 15 min
```

```text
🔴 **kwatch roll-up** · prod-eu-1 — 2 new problems at the same time

**Problems**
- **api** in **billing** keeps crashing
- **api** in **service-c** keeps crashing
- **api** in **shop** keeps crashing

*Each gets its own message when it changes or resolves.*
Expand Down
147 changes: 110 additions & 37 deletions RELEASES.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ the temporary copy. Only the Lease holder opens the file for writing, and every
write checks a claim epoch, so a process that lost the Lease cannot overwrite
newer state.

On Pro, a restart reloads the last 24 hours of change records (the newest 1024) and
On Pro, a restart restores the last 24 hours of change records (the newest 1024) and
each workload's last healthy time into the model, before the sources report,
with the original actors and times. The comparison of fingerprints with the
cluster then adds only what the records do not explain: a change the records
Expand Down
8 changes: 4 additions & 4 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,14 @@ status, resource versions, and deletion metadata remain intact.
name. The closing messages of those carry no problems and follow the
summary they close. Plain notices go to every provider.
- **Routing by owner.** Label or annotate a workload, or its namespace,
with `kwatch.dev/owner: payments`, and give a provider a route for it:
with `kwatch.dev/owner: service-b`, and give a provider a route for it:

```yaml
alert:
slack:
webhook: https://hooks.slack.com/services/T000/B000/payments
webhook: https://hooks.slack.com/services/T000/B000/service-b
routes:
- owners: ["payments"]
- owners: ["service-b"]
pagerduty:
routingKey: "...& 8000 quot;
routes:
Expand Down Expand Up @@ -1119,7 +1119,7 @@ The audit log is Pro: Community writes no audit log, and a file `output`
is listed at startup as an ignored setting.

Each line has `message` (one short sentence built from the other fields,
such as `deployment/web in prod: alert updated (still open)`) and `level`
such as `deployment/service-a in prod: alert updated (still open)`) and `level`
(`info` for the digest and silent tiers, `warning` for notify, `error` for
page), so a log tool shows a readable row and can filter by level.

Expand Down
27 changes: 27 additions & 0 deletions docs/contributing-scenario.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,33 @@ go test ./internal/scenarios -run TestScenarioRatchetHolds -update-ratchet
A scenario that opts out of the first-message gate with `RevisesRoot` is
still judged on its final root and still counts for the ratchet.

## Restore parity

Every other scenario test replays a log through one engine that never
restarts. `TestScenarioRestoreParity` restarts kwatch inside committed
scenarios: the first session saves its state through the real incident store
into a real state file and stops; a new engine restores from that file, gets
the initial list informers would deliver, and finishes the log. Each sampled
scenario restarts twice, in the middle of its log and just after its first
message. The restored run must end with the same open incidents (root,
members, tier, state) and the same cause and confidence level, and must tell
people the same after the restart as the uninterrupted replay.

One scenario in eight is sampled by a stable hash of its name.
`KWATCH_RESTORE_SAMPLE=N` samples one in N, `all` every scenario.

`internal/scenarios/testdata/restore_parity_known.txt` lists the scenarios
known to diverge today, with the kinds of divergence (`open`, `membership`,
`tier`, `state`, `cause`, `messages`) and the first difference found. A
listed scenario may diverge in the kinds its line names. Any other
divergence fails, and so does a listed kind that no longer diverges, so the
list only shrinks. After a fix, rewrite it and read the diff:

```sh
KWATCH_RESTORE_SAMPLE=all go test ./internal/scenarios \
-run TestScenarioRestoreParity -update-restore-parity
```

## Adversarial scenarios

`library_adversarial_*_test.go` holds scenarios written by someone who did
Expand Down
31 changes: 19 additions & 12 deletions docs/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ alerts are on. Rows per page is the one control under the Issues table.
## Browser alerts

**Browser alerts**, on the Settings page, turns on
browser notifications for this browser: kwatch sends each change at the
browser notifications for this browser. They are on by default for
Urgent and Needs attention issues: a browser that already allows
notifications for the dashboard gets them at once, and otherwise one
prompt, "Turn on alerts for Urgent and Needs attention issues", asks
(the browser only allows them after a click); "No thanks" or turning
them off is kept. kwatch sends each change at the
level you pick through the browser's push service (Web Push, encrypted
for that browser), so they arrive with every dashboard tab closed and
stay on screen until closed. They are for confirmed issues only: an
Expand Down Expand Up @@ -154,15 +159,17 @@ there, then turn on alerts."
before you set `oldProblemDays`, or kept from before a restart) moves
to this list without a message.
- **Issues** (`/issues`): every issue in one table, with search, filters
and saved views. Active, Resolved and All are tabs on it, and the
Active list has its own tabs, each with its count: **Needs attention**
(opens first), **Ongoing** (open for over a day and unchanged since:
it did not recover, come back or flap), **Cleanup** (leftovers that
are not urgent: groups of objects a removed controller left behind,
objects stuck while deleted, unused Services or claims, expired
certificates) and **All active**. A link with filters (from the
Overview, a saved view) opens on All active, as before; the tab is in
the address (`bucket=ongoing`). An issue that
and saved views. Active, Resolved and All are tabs on it; with no
filter, Active shows every active issue. The quick views
**Ongoing** (open for over a day and unchanged since: it did not
recover, come back or flap) and **Cleanup** (leftovers that are not
urgent: groups of objects a removed controller left behind, objects
stuck while deleted, unused Services or claims, expired certificates)
narrow it like any filter (`bucket=ongoing` in the address). Old
links with `bucket=attention` or `bucket=all` open every active
issue. A saved view keeps the filters, search, order and columns;
View options can update it with what is shown, rename it, make it 8BD0
the default or delete it. An issue that
groups the objects a removed controller left behind carries a small
"12 objects" chip.
- **Issue page** (`/issues/<id>`): one issue, as plain questions, with the
Expand Down Expand Up @@ -305,9 +312,9 @@ may say more than the address does.
the last hour, or 7 days), newest first; the window you pick last is
kept in this browser. Each row shows the clock time and how long ago
("14:02", "2 h ago"); the issue's title is its tooltip. Each row is a sentence: "api in shop: resolved after
12 min", "warehouse in shop: became Urgent (alerted the on-call person)" (with
12 min", "service-a in shop: became Urgent (alerted the on-call person)" (with
no pager connected: "sent as urgent"),
"tracking in staging: settled on its own". The line at the top counts
"worker in staging: settled on its own". The line at the top counts
the changes in words ("25 issues started, 4 got more urgent and 21
resolved"). Four or more of the same change in one minute fold behind "8
more resolved at 14:55". A resolve carries `lasted`, the seconds the issue
Expand Down
2 changes: 1 addition & 1 deletion docs/incident-lifecycle/announce.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ It notifies, and an incident that paged for a real outage falls back to
notify once nothing pages any more and the previous version serves again
(`easePage`); a new outage pages through the usual raise. The fall-back
owes the providers that keep alerts by key one update, reason `tier
lowered` (`loweredStep`), sent once and not held by `MaterialGap`: "web in
lowered` (`loweredStep`), sent once and not held by `MaterialGap`: "service-a in
shop is no longer urgent: the previous version serves again; only the new
rollout fails". It is paging-only (`PagingOnly`), so chat is not told; when
other news is due at the same time it is one material update to every
Expand Down
2 changes: 1 addition & 1 deletion docs/incident-lifecycle/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Ten workloads crash with the same line, `license key rejected for tenant
it next to the probe result; a Community message never does. When
nothing else explains the incident, that answer is the lead
(`compose/probe_lead.go`), with what the probe asks from its spec
(`probe check` evidence): "web in shop is not ready: its readiness
(`probe check` evidence): "service-a in shop is not ready: its readiness
check (/readyz on port 8081) answers HTTP 503", and the Pro proof
then adds only "From its log: ..."; a liveness check reads "is restarted: ...", a startup check "can't
finish starting: ...", a check that timed out "does not answer
Expand Down
4 changes: 2 additions & 2 deletions docs/incident-lifecycle/reminders.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ failure right now; one that recovers, or flaps and is healthy at the
moment, is left out, because "still failing" would be false:
`stillFailing` in `announce/ongoing.go`)
is therefore named again in the digests that go out, as an ongoing item
in the Problems list: `Service web (shop) is still failing, for two days
in the Problems list: `Service service-a (shop) is still failing, for two days
now.` Each ongoing item is listed in full at most once a day (UTC): in the
first digest of the day, or when it changed (flapping, its reason, how many
things fail, its cause). A problem that began more than `WeeklyAfter` (7
days) ago and did not change is listed in full at most once a week (ISO
week, UTC): the first digest of the week lists it with the others still
open. Other digests carry one line for the rest: `3 more
still failing, unchanged (web, db, cache +1)`. The audit entry of a digest
still failing, unchanged (service-a, db, cache +1)`. The audit entry of a digest
names every ongoing item. The list is capped like the rest (five, then
`+N more still failing`; `announce/ongoing_compact.go`).

Expand Down
4 changes: 2 additions & 2 deletions docs/incident-lifecycle/resolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ with the listing as `carrier`, not as `not routed`.

## What a resolve says

`compose.resolveNote` leads with how the subject ended ("payments in shop
`compose.resolveNote` leads with how the subject ended ("service-b in shop
is healthy again."), then who fixed it when the fixing change is known,
how long it was failing and what it was blamed on. Not every change can
be the fix (`notAFix` in `history.go`): a scale is a reaction, a node's
Expand All @@ -131,7 +131,7 @@ survives the members leaving and a restart.
A resolve at the `StillBrokenMax` cap does not say the incident is healthy.
Its lead says what is still wrong: "X still has a container that keeps
crashing.", "X is still short of replicas." or, for a subject without
replicas, "X has not recovered.". Then it says "kwatch stopped tracking this
replicas, "X has not recovered.". Then it says "kwatch stopped watching this
after 2h; it is still not healthy, so check it yourself." (`stoppedTracking`
in `compose/resolve.go`).

Expand Down
24 changes: 17 additions & 7 deletions docs/production-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ the real cluster before trusting the table.

**The working set is more than the Go heap.** `kubectl top` and the
dashboard's Resources card show the container's working set, which adds
to the Go runtime's memory (`goMemoryMiB` in the `self-health` line: the
heap, goroutine stacks and the runtime's own structures) the pages of the
to the Go runtime's memory (`goHeldMiB` in the `self-health` line: the
heap, goroutine stacks and the runtime's own structures it holds and has
not given back) the pages of the
state file kwatch has read. bbolt maps the whole file into memory, and
reading it (restoring incidents at start, the compactor's passes) brings
those pages in; they count toward the container's memory although the
Expand All @@ -338,9 +339,14 @@ compaction pass` line, `fileBytes`) to the heap figure below.
**The page cache is counted but reclaimable.** The kernel counts the state
file's cached pages in the container's working set, and drops them under
pressure before it kills anything. A working set near the limit is therefore
not by itself a problem. Alert on Go memory (`goMemoryMiB` in the
not by itself a problem. Alert on Go memory (`goHeldMiB` in the
`self-health` line, or the Go heap series), not on the working set: the
working set includes the cache and will sit high on a busy cluster.
working set includes the cache and will sit high on a busy cluster. Do
not alert on `goReservedMiB`: it is the address space the runtime ever
reserved (Go's `Sys`), including heap already returned to the system.
It is not resident, never shrinks, and often reads well above the
working set (449 MiB beside a 229 MiB working set and a 70 to 86 MiB
live heap on a cluster watching 234 kinds).

**State file size.** Three sizes differ. The logical size is the key and
value bytes the compactor measures (`logicalBytes`, with `<bucket>Bytes` for
Expand Down Expand Up @@ -392,7 +398,11 @@ number of goroutines and the sizes of its bounded in-memory maps, so slow
growth shows in the logs before the limit does. Its `stackInuseMiB`
(goroutine stacks), `heapIdleUnreleasedMiB` (free heap not yet returned
to the system) and `gcSysMiB` (the collector's metadata) explain most of
the gap between the heap and `goMemoryMiB`.
the gap between the heap and `goHeldMiB`. The line's `goroutines` grows
with the watched resource types: each one runs its own watch, about 9
goroutines in client-go (reflector, its resync timer, the watch stream
and its HTTP/2 stream, the event queue and one handler), so about 2,450
goroutines for 234 kinds is normal and stays flat.

The chart takes the container and probe port from `config.healthCheck.port`
(default 8060) and refuses to render with `config.healthCheck.enabled: false`,
Expand Down Expand Up @@ -767,7 +777,7 @@ it, so a replay of the export sees the same evidence kwatch saw:
(`volume_name`, `pvc/name`), so "dial tcp name-3f1c…:9000" still names
that Service;
- a name right after a Kubernetes kind is hidden even when kwatch never
saw the object (`configmap "billing-config" not found`, `Secret
saw the object (`configmap "service-c-config" not found`, `Secret
db-creds`, `deployments.apps "api"`), with the pseudonym the object
gets if it appears later; so are the object and namespace labels of a
cluster DNS name;
Expand All @@ -785,7 +795,7 @@ as text: a setting may hold a secret no pattern recognises. Scrubbing is a
pattern match, not a guarantee: a plain word that is also a name kwatch
never saw as an object or after a kind word, a dotted name written like
code (a type, `Db.Example.Error`, or a type and a method,
`Billing.corp`), a host whose last label is also a file extension
`Service-c.corp`), a host whose last label is also a file extension
(`mycorp.sh`), and names shorter than 3 characters stay. A namespace
or object named like a common word (`default`, `app`, `api`) stays a
word in text unless a kind word names it. Read an export before sharing
Expand Down
10 changes: 5 additions & 5 deletions docs/specs/core-round-2026-11.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ Two forms. Never claims a future. The requested line "this will likely return" i

3a. Healthy, cause still present (e.g. cause was a config pointing at a dead host, restart cleared the crash):
```
✅ payments in shop is healthy again after a restart, but db.example.com:5432 still refuses connections. The same cause is still present; kwatch will keep watching it. To check it, run kubectl logs payments-6d4f-0 -c app -n shop
✅ service-b in shop is healthy again after a restart, but db.example.com:5432 still refuses connections. The same cause is still present; kwatch will keep watching it. To check it, run kubectl logs service-b-6d4f-0 -c app -n shop

✅ payments in shop is healthy again after a restart, but db.example.com:5432 still refuses connections.
✅ service-b in shop is healthy again after a restart, but db.example.com:5432 still refuses connections.
```
"kwatch will keep watching it" is allowed only if the code does keep the incident or a follow-up open (core to verify; else delete the clause). Form: `<what recovered> after <action>, but <cause> still <state>.` `<state>` is the present tense observed state ("refuses connections", "is full at 98%").

3b. Cause confirmed recovered (plain resolve, as today):
```
✅ payments in shop is healthy again. db.example.com:5432 accepts connections again. It was failing for 38 minutes.
✅ service-b in shop is healthy again. db.example.com:5432 accepts connections again. It was failing for 38 minutes.

✅ payments in shop is healthy again.
✅ service-b in shop is healthy again.
```
Before: `✅ payments in shop is healthy again. It was failing for 38 minutes.` (resolved_without_fix.golden). The new sentence appears only when the cause was named and its recovery was observed.
Before: `✅ service-b in shop is healthy again. It was failing for 38 minutes.` (resolved_without_fix.golden). The new sentence appears only when the cause was named and its recovery was observed.

Dashboard: header stays "lasted 38 min, resolved 14:02". Stepper "Resolved" gets a second line when 3a: "Resolved, cause still present" and the Why row keeps the cause with a `Still present` label in `--text` (text, not colour); 3b shows `Recovered 14:02` on the Why row. Tooltip on "cause still present": "The app is healthy, but the thing that was breaking it has not recovered. kwatch checked again at resolve time." Alerts tab "What we sent" shows the exact text.

Expand Down
2 changes: 1 addition & 1 deletion docs/upgrading-to-1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ v0.10.x install has no license key, so v1.0.0 starts it as Community, and
silences keep working. `kwatch lint` lists
everything that is ignored.
- A Community alert says what broke and the type of cause, never which
object, change, image or version it is: "payments in shop keeps
object, change, image or version it is: "service-b in shop keeps
crashing. Most likely cause: a config change." The exact cause and its
proof, the commands to run, the fix ("Fix: change the image of container
app in deployment/api ...") and how often it happened before ("This is
Expand Down
4 changes: 2 additions & 2 deletions internal/alert/alerta/incident_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ func TestAlertaClassifiesErrors(t *testing.T) {
func TestAlertaUsesStableDedupKeyAsResource(t *testing.T) {
c, rec := newTestAlerta(t)
msg := providertest.Lifecycle()[0].Message
msg.DedupKey = "deployment-shop-payments-crashloop"
msg.DedupKey = "deployment-shop-service-b-crashloop"

require.NoError(t, c.SendIncident(context.Background(), msg))

assert.Equal(t, "dev/kwatch-deployment-shop-payments-crashloop",
assert.Equal(t, "dev/kwatch-deployment-shop-service-b-crashloop",
rec.Last(t).JSON(t)["resource"])
}

Expand Down
6 changes: 3 additions & 3 deletions internal/alert/alerta/testdata/contract/linked.golden
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Authorization: Key <redacted>
{
"attributes": {
"reason": "OOMKilled",
"summary": "🔴 payments in shop is crash-looping."
"summary": "🔴 service-b in shop is crash-looping."
},
"environment": "Staging",
"event": "incident",
Expand All @@ -14,6 +14,6 @@ Authorization: Key <redacted>
"kwatch"
],
"severity": "critical",
"text": "🔴 payments in shop is crash-looping.\nCaused by: Node n1 is not ready.\nCause in dashboard: https://kwatch.example/issues/p-cause\nEarlier times: https://kwatch.example/issues?status=all&like=p-link\nOpen in dashboard: https://kwatch.example/issues/p-link\n\nLast output:\npanic: out of memory",
"value": "🔴 payments in shop is crash-looping."
"text": "🔴 service-b in shop is crash-looping.\nCaused by: Node n1 is not ready.\nCause in dashboard: https://kwatch.example/issues/p-cause\nEarlier times: https://kwatch.example/issues?status=all&like=p-link\nOpen in dashboard: https://kwatch.example/issues/p-link\n\nLast output:\npanic: out of memory",
"value": "🔴 service-b in shop is crash-looping."
}
Loading
Loading
0