UID2-7063: Emit salts_rotated_last_cycle Prometheus gauge#636
Closed
swibi-ttd wants to merge 1 commit into
Closed
Conversation
Adds a Micrometer gauge `uid2_salts_rotated_last_cycle` that records the count of salts rotated in the most recent successful salt rotation cycle. The gauge reports NaN until the first rotation completes so the volume alert does not fire on cold start. Lets the salt-rotation volume alert key off a Prometheus metric instead of Loki log scraping, which has produced false positives when log ingestion glitches (Alloy re-streams, Loki push failures).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
uid2_salts_rotated_last_cycle, a Micrometer gauge emitted by uid2-admin that records the count of salts rotated in the most recent successful salt rotation cycle.NaNuntil the first rotation completes, so any equality-based alert built on it does not fire on cold start.Main.setupMetricsviaSaltRotationMetrics.register(Metrics.globalRegistry), alongside the existingDataStoreMetricsregistrations.SaltRotation.rotateSaltscallsSaltRotationMetrics.recordRotated(saltsToRotate.size())after a successful rotation; the metric is not touched whenrotateSaltsreturnsnoSnapshotor whenrotateSaltsZeroruns (which rotates no salts by design).Why
Ticket: UID2-7063.
The existing
P*.{PROD,INTEG}.Admin.Salt.UnexpectedSaltRotationVolumealerts key off a Loki log query (salt_count_type=rotated-salts). That has produced false positives when log ingestion glitches (Alloy re-streams, Loki push failures). A Prometheus gauge is sampled at scrape time and immune to that class of issue.Follow-ups (not in this PR)
uid2-monitoring-configuration#swi-UID2-7063. That PR should be merged after this one is deployed through integ → prod, so the metric exists by the time the alert switches to query it.c58e015d-b1f3-4a66-8b32-0bef4149540e) is managed in the Grafana UI, not as JSON in the monitoring repo. Adding a panel for the new metric needs to happen there (UID2 grafana.net, which auto-syncs to EUID).Test plan
mvn test -Dtest=SaltRotationTest— 37 tests pass (34 existing + 3 new)mvn test -Dtest='SaltRotationTest,SaltServiceTest,SaltSerializerTest,EncryptedSaltStoreWriterTest'— 51 tests passmvn compilecleanuid2_salts_rotated_last_cycle{env="integ",application="uid2-admin"}appears in Grafana Cloud and matches the count in thesalt_count_type=rotated-saltslog on the next rotation cycle