Skip to content

backend/instances.go: fix instance stats query#1356

Merged
t-lo merged 1 commit intomainfrom
t-lo/fix-instance-stats
Apr 10, 2026
Merged

backend/instances.go: fix instance stats query#1356
t-lo merged 1 commit intomainfrom
t-lo/fix-instance-stats

Conversation

@t-lo
Copy link
Copy Markdown
Member

@t-lo t-lo commented 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 query 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.

@t-lo t-lo requested a review from a team as a code owner April 9, 2026 16:38
@t-lo t-lo force-pushed the t-lo/fix-instance-stats branch from 6c8b61b to be6cdb8 Compare April 9, 2026 16:39
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>
@t-lo t-lo force-pushed the t-lo/fix-instance-stats branch from c1693bc to 66d4e60 Compare April 10, 2026 08:33
@t-lo t-lo requested a review from ervcz April 10, 2026 08:33
@t-lo t-lo merged commit 37ec8b0 into main Apr 10, 2026
8 checks passed
@t-lo t-lo deleted the t-lo/fix-instance-stats branch April 10, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants