You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add a stable device_last_seen_timestamp_seconds{device_id} metric and use time() - max by (device_id)(...) for offline rules
refresh the timestamp metric from register/heartbeat/offline paths and prefer device last_seen_at when refreshing compatibility gauges
recover active metric_raw incidents from storage when their dedupe keys are absent from the current PromQL result, covering evaluator restarts and query label changes
Tests
go test ./internal/pkg/prom ./internal/manager/biz/edge ./internal/manager/biz/alert ./internal/manager/data/alert/store
go test -race ./internal/manager/biz/alert ./internal/manager/biz/edge ./internal/manager/data/alert/store
npm run typecheck
go test ./...
Author confirmation
I have read and agree to the project contribution guide in CONTRIBUTING.md.
device_offline is still seeded with global scope. The PromQL result has device_id, but evaluatePromQuery only fills FiringInput.DeviceID for host-scoped rules. That means the offline incident is not reliably attached to the actual Device row, so device-level UI/actions/RCA context can lose the target.
resolveRecoveredPromQueryIncidents scans active incidents on every evaluator tick: 3 statuses x up to 10000 rows x every metric_raw rule. That is too much work for the hot alert loop and will get worse as rules/incidents grow. Please make recovery targeted, for example keep the in-memory previous-firing path for normal operation and use a bounded startup/backfill path, or add a narrower repo query for active incidents by rule/status/dedupe keys instead of broad scans each tick.
After those are fixed, the direction is good: device LastSeenAt should be the source for heartbeat gauges.
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
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
device_last_seen_timestamp_seconds{device_id}metric and usetime() - max by (device_id)(...)for offline ruleslast_seen_atwhen refreshing compatibility gaugesTests
go test ./internal/pkg/prom ./internal/manager/biz/edge ./internal/manager/biz/alert ./internal/manager/data/alert/storego test -race ./internal/manager/biz/alert ./internal/manager/biz/edge ./internal/manager/data/alert/storenpm run typecheckgo test ./...Author confirmation