Skip to content

Commit c1c5ebd

Browse files
committed
fix(cluster): fix scaling logic and dedup metrics
1 parent 5c607af commit c1c5ebd

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

packages/core/services/cluster/src/ops/datacenter/topology_get/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ pub async fn cluster_datacenter_topology_get(
118118
FROM db_cluster.servers
119119
WHERE
120120
datacenter_id = ANY($1) AND
121-
cloud_destroy_ts IS NULL AND
122-
taint_ts IS NULL
121+
cloud_destroy_ts IS NULL
123122
",
124123
&input.datacenter_ids,
125124
)

packages/core/services/cluster/src/ops/datacenter/topology_get/pegboard.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ pub async fn pegboard_client_usage_get(ctx: &OperationCtx, input: &Input) -> Glo
3737
r#"
3838
label_replace(
3939
sum by (client_id) (
40-
last_over_time(
41-
rivet_pegboard_client_cpu_allocated{{
42-
client_id=~"({client_ids})",
43-
}}
44-
[15m:15s]
40+
rivet_pegboard_client_cpu_allocated{{client_id=~"({client_ids})"}}
41+
# This "and on" deduplicates metrics by their inherent timestamp, choosing the latest data
42+
and on(client_id, instance) (
43+
timestamp(rivet_pegboard_client_cpu_allocated{{client_id=~"({client_ids})"}}) ==
44+
scalar(max(timestamp(rivet_pegboard_client_cpu_allocated{{client_id=~"({client_ids})"}})))
4545
)
4646
),
4747
"metric", "cpu", "", ""
4848
)
4949
OR
5050
label_replace(
5151
sum by (client_id) (
52-
last_over_time(
53-
rivet_pegboard_client_memory_allocated{{
54-
client_id=~"({client_ids})",
55-
}}
56-
[15m:15s]
52+
rivet_pegboard_client_memory_allocated{{client_id=~"({client_ids})"}}
53+
# This "and on" deduplicates metrics by their inherent timestamp, choosing the latest data
54+
and on(client_id, instance) (
55+
timestamp(rivet_pegboard_client_memory_allocated{{client_id=~"({client_ids})"}}) ==
56+
scalar(max(timestamp(rivet_pegboard_client_memory_allocated{{client_id=~"({client_ids})"}})))
5757
)
5858
),
5959
"metric", "mem", "", ""

0 commit comments

Comments
 (0)