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

Prometheus – add target specific label in static_configs

I have the same question before. Here is my solution: use job_name as the group label add more target option to separate instance and add labels For you the code may like this: – job_name: ‘development’ static_configs: – targets: [ ‘192.168.1.1:9100’ ] labels: service: ‘1’ – targets: [ ‘192.168.1.1:9101’ ] labels: service: ‘2’

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