How to use the selected period of time in a query?

There are two ways that I know: You can use the $__interval variable like this: increase(http_requests_total[$__interval]) There is a drawback that the $__interval variable’s value is adjusted by resolution of the graph, but this may also be helpful in some situations. This approach should fit your case better: Go to Dashboard’s Templating settings, create new … Read more

How can I group labels in a Prometheus query?

Yes, you can you use label replace to group all the misc together: sum by (new_group) ( label_replace( label_replace(my_metric, “new_group”, “$1”, “group”, “.+”), “new_group”, “misc”, “group”, “misc group.+” ) ) The inner label_replace copies all values from group into new_group, the outer overwrites those which match “misc group.+” with “misc”, and we then sum by … Read more

Get Total requests in a period of time

What you need is the increase() function, that will calculate the difference between the counter values at the start and at the end of the specified time interval. It also correctly handles counter resets during that time period (if any). increase(http_requests_total[24h]) If you have multiple counters http_requests_total (e.g. from multiple instances) and you need to … Read more