-
Notifications
You must be signed in to change notification settings - Fork 2
/
data-query.sh
executable file
·43 lines (31 loc) · 2.04 KB
/
data-query.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# - Current (per 3 seconds) (`curr`)
# - Total (accumulative) (`total`)
# - By resource
# - Sum in namespace (`sum[...]`)
# - Compute (`pkg`)
# - Memory (`dram`)
# - Pod (`pod_name`)
# - Namespace (`pod_namespace`)
echo "1. Current"
echo "each separate resource"
curl -sG http://localhost:9090/api/v1/query --data-urlencode "query=pod_curr_energy_in_pkg_millijoule{pod_namespace='flux-system'}" | jq
echo "total in namespace"
curl -G http://localhost:9090/api/v1/query --data-urlencode "query=sum(pod_curr_energy_in_pkg_millijoule{pod_namespace='flux-system'})" | jq '.data.result[0].value[0]'
echo "2. Accumulative"
echo "each separate resource"
curl -G http://localhost:9090/api/v1/query --data-urlencode "query=sum(pod_total_energy_in_pkg_millijoule{pod_namespace='flux-system'})"
echo "total in namespace"
curl -G http://localhost:9090/api/v1/query --data-urlencode "query=sum(pod_total_energy_in_pkg_millijoule{pod_namespace='flux-system'})" | jq '.data.result[0].value[0]'
echo "3. Compute-only"
echo "each separate resource"
curl -G http://localhost:9090/api/v1/query --data-urlencode "query=sum(pod_curr_energy_in_pkg_millijoule{pod_namespace='flux-system'})" | jq '.data.result[0].value[0]'
echo "total in namespace"
curl -G http://localhost:9090/api/v1/query --data-urlencode "query=sum(pod_total_energy_in_pkg_millijoule{pod_namespace='flux-system'})" | jq '.data.result[0].value[0]'
echo "4. Memory-only"
echo "each separate resource"
curl -G http://localhost:9090/api/v1/query --data-urlencode "query=sum(pod_curr_energy_in_dram_millijoule{pod_namespace='flux-system'})" | jq '.data.result[0].value[0]'
echo "total in namespace"
curl -G http://localhost:9090/api/v1/query --data-urlencode "query=sum(pod_curr_energy_in_dram_millijoule{pod_namespace='flux-system'})" | jq '.data.result[0].value[0]'
echo "get the actual energy consumption of all the pods in a namespace in the last min"
curl -sG http://localhost:9090/api/v1/query --data-urlencode "query=rate(pod_curr_energy_millijoule{pod_namespace='flux-system'}[1m])/3" | jq '.data.result[0].value[0]'