Skip to content

Commit c0a9c3b

Browse files
committed
fix: add max by to topo queries (#2645)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
1 parent bc97b4a commit c0a9c3b

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

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

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -473,49 +473,53 @@ async fn fetch_server_metrics(
473473
r#"
474474
label_replace(
475475
# Add up all millicores from all cpus
476-
sum by (datacenter_id, pool_type, server_id) (
477-
last_over_time(
478-
irate(
479-
node_cpu_seconds_total{{
480-
server_id=~"({server_ids})",
481-
482-
mode!="idle",
483-
mode!="iowait",
484-
mode!="steal"
485-
}}
486-
[5m]
476+
sum by (server_id) (
477+
max by (server_id, mode) (
478+
last_over_time(
479+
irate(
480+
node_cpu_seconds_total{{
481+
server_id=~"({server_ids})",
482+
483+
mode!="idle",
484+
mode!="iowait",
485+
mode!="steal"
486+
}}
487+
[5m]
488+
)
489+
[3h]
487490
)
488-
[15m:15s]
489491
)
490-
# Millicores
491-
* 1000
492-
),
492+
)
493+
# Millicores
494+
* 1000,
493495
"metric", "cpu", "", ""
494496
)
495497
OR
496498
label_replace(
497499
# Selects the memory usage of a server in bytes
498-
max by (datacenter_id, pool_type, server_id) (
500+
max by (server_id) (
499501
node_memory_Active_bytes{{
500502
server_id=~"({server_ids})",
501503
}}
502-
# MiB
503-
/ 1024 / 1024
504-
),
504+
)
505+
# MiB
506+
/ 1024 / 1024,
505507
"metric", "mem", "", ""
506508
)
507509
OR
508510
label_replace(
509511
# Selects the bandwidth usage of a server
510-
sum by (datacenter_id, pool_type, server_id) (
511-
last_over_time((
512-
irate(
513-
node_network_transmit_bytes_total{{
514-
server_id=~"({server_ids})",
515-
device=~"(eth0|eth1)"
516-
}}[1m]
517-
)
518-
) [1m:15s])
512+
sum by (server_id) (
513+
max by (server_id, device) (
514+
last_over_time((
515+
irate(
516+
node_network_transmit_bytes_total{{
517+
server_id=~"({server_ids})",
518+
device=~"(eth0|eth1)"
519+
}}[1m]
520+
)
521+
) [3h])
522+
)
519523
)
520524
# Convert from B/s to Kb/s
521525
* 8 / 1000,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ pub async fn pegboard_client_usage_get(ctx: &OperationCtx, input: &Input) -> Glo
3636
formatdoc!(
3737
r#"
3838
label_replace(
39-
sum by (client_id) (
40-
rivet_pegboard_client_cpu_allocated{{client_id=~"({client_ids})"}}
39+
max by (client_id) (
40+
last_over_time(rivet_pegboard_client_cpu_allocated{{client_id=~"({client_ids})"}} [3h])
4141
),
4242
"metric", "cpu", "", ""
4343
)
4444
OR
4545
label_replace(
46-
sum by (client_id) (
47-
rivet_pegboard_client_memory_allocated{{client_id=~"({client_ids})"}}
46+
max by (client_id) (
47+
last_over_time(rivet_pegboard_client_memory_allocated{{client_id=~"({client_ids})"}} [3h])
4848
),
4949
"metric", "mem", "", ""
5050
)

0 commit comments

Comments
 (0)