1

I've just a service that creates 2 files each 30 seconds on a specific directory using python, and I'm using Prometheus/Grafana to evaluate the number of files being uploaded over time, with the metric that I've created on Prometheus named txt_files_data__total. Sometimes I just upload more files to my directory manually so I can see the variance on my chart.

My main goal is to calculate two expressions using Grafana:

  • The number of files being generated by each minute
  • Validate if the number of files being generated each minute is very different by the average number of files generated each minute on the last 24h.

For the first expression, I am able to calculate using:

increase(txt_files_data__total{instance="localhost:9999",job="python"}[1m])

But my second expression is giving abnormal numbers (my calculation is that I should have a value like 4.777 but I am getting 30/40 number of files):

avg_over_time(txt_files_data__total{instance="localhost:9999",job="python"}[24h:1m])

I just export the Grafana data as a table:

enter image description here

And you can see the grafana chart: enter image description here

Am I making any mistake calculating those metrics?

Many thanks for your help

tech_data
  • 31
  • 3

1 Answers1

0

The following query must return the average number of files being generated per minute over the last 24 hours:

avg_over_time(
  increase(txt_files_data__total{instance="localhost:9999",job="python"}[1m])[20s:24h]
)

This query uses subquery feature.

valyala
  • 11,669
  • 1
  • 59
  • 62