I have a number of Prometheus queries in a Grafana panel that use this structure:
sum(avg_over_time(cluster:capacity_cpu_cores:sum[$__range]))
/ $number_of_CPU_cores_per_server
* ($__range_s / $seconds_in_server_lifespan)
* ($cost_of_server_CPU)
Each of these queries uses the same Prometheus query sum(avg_over_time(cluster:capacity_cpu_cores:sum[$__range]))
but uses different denominators and multipliers (e.g. / $bytes_of_memory_in_physical_server
or * ($cost_of_software_license_A)
).
The dashboard works as intended, unless we specify a time range greater than two days, in which case the dashboard fails to update.
Assuming the update failure is due to the large number of Prometheus queries being made, is there a way to make the sum(avg_over_time(cluster:capacity_cpu_cores:sum[$__range]))
query only once per refresh?