Hi,
I am trying to create a graph in Grafana that shows the hourly byte consumption of a specific HAProxy backend over the last 24 hours. Additionally, I want to add a reference line that shows the average of this value over the last 7 days for each hour. To ensure the metric is correct, I would also like to add a third metric that shows the average of this value over the last 24 hours, by hour, for comparison.
Here is what I need to achieve:
- First Metric: Hourly growth value of the metric
haproxy_backend_bytes_in_total{}
over the last 24 hours. - Second Metric: Average of this value over the last 7 days, for each hour.
- Third Metric: Average of this value over the last 24 hours, by hour, for comparison.
Problems Encountered:
- The calculated average is producing linear results, which is not expected.
- I cannot correctly calculate the hourly average over the last 7 days.
I have attached an image with the current graph and the queries I am using. Here are the queries I used:
Query A: Hourly Consumption Over the Last 24 Hours
sum by (backend) (increase(haproxy_backend_bytes_in_total{backend="app-service_8080"}[1h]))
Query B: Hourly Consumption Over the Previous 24 Hours
sum by (backend) (increase(haproxy_backend_bytes_in_total{backend="app-service_8080"}[1h] offset 24h))
Query C: Hourly Consumption Over the Second Previous 24 Hours
sum by (backend) (increase(haproxy_backend_bytes_in_total{backend="app-service_8080"}[1h] offset 48h))
Query D: Average Over the Last 7 Days
avg_over_time(sum by (backend) (increase(haproxy_backend_bytes_in_total{backend="app-service_8080"}[1h]))[7d:])
Questions:
- How can I adjust my queries to get the correct hourly average over the last 7 days?
- Is there a better way to structure these queries to achieve my goals?
- Any suggestions on how to ensure the comparison data is correct?
Attached Image: