Keycloak health probes, metrics and memory alerts #573
Etiketter
Inga etiketter
area/backups
area/ci
area/control-panel
area/identity
area/infra
area/observability
area/payments
area/security
area/storage
area/web
blocked
needs-info
needs-triage
priority
high
priority
low
priority
medium
ready-for-implementation
type
bug
type
chore
type
docs
type
epic
type
feature
type
task
wontfix
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Inget förfallodatum satt.
Beroenden
Inga beroenden satta
Referens
bitborg/bitborg-infra#573
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "%!s()"
Borttagning av en gren är permanent. Även om den borttagna grenen kan fortsätta existera en kort tid innan den faktiskt tas bort, kan det INTE ångras i de flesta fall. Vill du fortsätta?
Monitor Keycloak and alert before it fails.
/realms/bitborg/.well-known/openid-configurationreplaces/status. Update sign-in chain probes.:9000/metrics. Add a unit-active metric forkeycloak.MemoryMaxfor 10 minutes, any OOM kill of the unit, not ready for 2 minutes, brute-force lockouts above a threshold.SignupProvisioningFailingto the new log prefix.Done when: each alert fires in a test and the runbook covers the listed procedures.
Depends on: #570
Epic: bitborg/bitborg-docs#127
#640 merged. Two thresholds differ from the issue text, by decision 2026-10-10:
MemoryMax, not 90 %.MemoryHighthrottles at 87.5 %, so 90 % would never be reached.HealthStartPeriod.Proven by vmalert-tool unit tests:
KeycloakNotReady,KeycloakMemoryHighandCoreUnitDownforkeycloak. The Loki rules for OOM, lockout and the sign-up prefix are checked against sample log lines.Left:
KeycloakLoginLockoutsmatcher against real Loki lines: enough bad passwords on a test user to lock it.KeycloakMemoryHighfire and no-fire cases are covered by the vmalert-tool unit tests inalert-rules.test.yml(#640).scripts/test-alert-rules.pypasses. Raising the fixture's current value to 75% makes the fire case fail, so the test can fail.Live check, 2026-10-11:
bitborg_unit_memory_current_bytesandbitborg_unit_memory_max_byteshave 0 series. The monitoring VM scrapes only the prod host, and prod does not run Keycloak yet. So the alert cannot fire live before cutover.#654: the unit and container alert annotations printed the scrape address (
node-exporter:9100). They now print$labels.host.Remaining after cutover: confirm the ratio series returns a value and the rule shows as inactive in vmalert.
Status 2026-10-11 after the cutover: Keycloak runs on prod, so its series are scraped.
KeycloakMemoryHighfired live on prod at 833 MB of 1 GiB (the heap flag was dropped by a Quadlet quoting bug, fixed in #666). That is a real firing. Probes now use/realms/bitborg/.well-known/openid-configurationand/user/oauth2/Bitborg-id. OOM, not-ready and lockout alerts are covered by the vmalert unit tests (#654). Open: the runbook procedures listed in the body (bootstrap, break-glass, secret rotation, upgrade, delete a user, restore) should be checked against the runbook before closing.Check 2026-10-11 evening.
id.bitborg.se/realms/bitborg/.well-known/openid-configurationreturns 1. Thekeycloak:9000scrape is up.KeycloakNotReadyandKeycloakMemoryHighare loaded in vmalert and inactive. Memory is at 64 % of MemoryMax after theMALLOC_ARENA_MAX=2apply (#671/#672).bitborg-keycloakholds 2 rules (KeycloakOOMKilled,KeycloakLoginLockouts), evaluating with 0 failures (loki_prometheus_rule_*on the Loki host).Open: prove
KeycloakLoginLockoutson a real lockout. A realLOGIN_ERRORline has the shape the matcher expects, but nouser_temporarily_disabledline has been logged yet.Lockout matcher verified live on 2026-10-18. A throwaway user (
lockout-test, since deleted) failed 10 logins on the account console, and the next attempts were refused. Keycloak loggedtype="LOGIN_ERROR" ... error="user_temporarily_disabled" ... username="lockout-test"twice. TheKeycloakLoginLockoutsLogQL selector,count_over_time({container="keycloak"} |~ \type="?LOGIN_ERROR"?.*error="?user_(temporarily|permanently)_disabled` [30m])`, returned 2. The alert threshold (more than 20 in 10 min) was not reached, as intended. The UI shows "Invalid username or password" to a locked user by design, so the lock does not leak.Earlier checks:
SignupProvisioningFailingmatches today's[signup] Keycloakprefix, and the runbook covers every procedure in the list. Every done-when item is met.