Closed
Description
As a requirement we need to know, how much power consumption has our platform in general, that means multiple cluster on multiple environments. If we have no multi-cluster monitoring in place, we can collect the information from each cluster:
- The current power consumption of container workload in Joule. 1 Joule = 1 Wattsekunde = 1 VAs. This can be a very large number:
kubectl curl -n cattle-monitoring-system "http://prometheus-rancher-monitoring-prometheus-0:9090/api/v1/query?query=sum(kepler_container_package_joules_total)" | jq -r '.data.result[]|.value[-1]'
128948308.37400006
ask the same and convert to more readable, let's say MegaJoule
kubectl curl -n cattle-monitoring-system "http://prometheus-rancher-monitoring-prometheus-0:9090/api/v1/query?query=sum(kepler_container_package_joules_total)%2F1000%2F1000" | jq -r '.data.result[]|.value[-1]'
128.96780355300004
- The daily power consumption, collected in the common metric kWh:
kubectl curl -n cattle-monitoring-system "http://prometheus-rancher-monitoring-prometheus-0:9090/api/v1/query?query=sum(increase(kepler_container_package_joules_total%5B24h%3A1m%5D))%20*%200.00000027777777777" | jq -r '.data.result[]|.value[-1]'
10.91925820424631
This query is copied from the Kepler Grafana dashboard with the converting "watt_per_second_to_kWh", which is factor 0.0000002777777777 (1W*s = 1J and 1J = (1/3600000)kWh)
The same query for one hour
kubectl curl -n cattle-monitoring-system "http://prometheus-rancher-monitoring-prometheus-0:9090/api/v1/query?query=sum(increase(kepler_container_package_joules_total%5B1h%3A1m%5D))%20*%200.00000027777777777" | jq -r '.data.result[]|.value[-1]'
0.4499151308907774
Which is a better visualization for a status page or status dashboard? Joule is in real time (in the second), but not very common.
Cc: @y-eight
hint: data collected via kubectl, curl plugin to ask Prometheus API on Prometheus Pod.