2

I have some counter in Prometheus (Victoria metrics).

In Grafana I'm displaying it like this:

sum by (model_id) (increase(requests[$__interval]))

I would like to add variable in grafana, called downsample. Where I could pick 1h, or 6h or something. I want to see my data aggregated based on this time. Like if I say 1h, I would like my graph to have 1 point per hour with total number of requests per model during this hour.

The $__interval seems to change by grafana based on my time window. But If I try to put my 1h I get something completely untrue.

markalex
  • 8,623
  • 2
  • 7
  • 32
Nikola Borisov
  • 348
  • 1
  • 10

1 Answers1

1

But If I try to put my 1h I get something completely untrue.

You are getting correct data, it's just your interpretation is a bit wrong.

When you query sum by (model_id) (increase(requests[1h])) you got as a result total increase over last hour (from point on graph) for ever model_id. But it doesn't change steps of graph.

If you want to have a possibility for user to easily enforce bigger steps on graph, you can create Interval dashboard variable, ans use it (in form $myvariable in Min step option of Panel data (Query options above the query editor). And keep your query as is.

This will allow to set minimal step of graph. But be advised that you are not forcing Grafana to use it: Grafana can use even bigger value if needed. For example it prevents users from passing 1s as an interval, while having dashboard over last year, sending Grafana, Prometheus and network into a bit of troubles.

markalex
  • 8,623
  • 2
  • 7
  • 32