backend/instances.go: fix instance stats query#1356
Merged
Conversation
6c8b61b to
be6cdb8
Compare
ervcz
reviewed
Apr 9, 2026
The instance stats query contained a bug in which it only returned instances that have _last_ checked in within the given time window instead of all _active_ instances during the window. As a result, instance count was skewed and much lower than the actual amount of active instances. This change updates the quey from: last_check_for_updates > (ts - window_size) AND last_check_for_updates < ts to last_check_for_updates > (ts - window_size) AND instance_created_ts < ts . The change also updates the default window size from 2 hours to one day to better match our legacy instance count metrics. Co-authored-by: Ervin Racz <39372002+ervcz@users.noreply.github.com> Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
c1693bc to
66d4e60
Compare
ervcz
approved these changes
Apr 10, 2026
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.
The instance stats query contained a bug in which it only returned instances that have last checked in within the given time window instead of all active instances during the window.
As a result, instance count was skewed and much lower than the actual amount of active instances.
This change updates the query from:
to
The change also updates the default window size from 2 hours to one day to better match our legacy instance count metrics.