Help with Hourly Consumption Graph and Averages in Grafana Using HAProxy Metrics

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:

  1. First Metric: Hourly growth value of the metric haproxy_backend_bytes_in_total{} over the last 24 hours.
  2. Second Metric: Average of this value over the last 7 days, for each hour.
  3. 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:

  1. How can I adjust my queries to get the correct hourly average over the last 7 days?
  2. Is there a better way to structure these queries to achieve my goals?
  3. Any suggestions on how to ensure the comparison data is correct?

Attached Image:

Hey folks, any suggestion? I’m stucked with ideias.

Are you using Prometheus?

Is this your setup? Monitor HAProxy with Prometheus and Grafana Cloud | Grafana Cloud documentation.