Facundo Chambo
Facundo Chambo

Reputation: 3398

Simple Prometheus counters query

I'm trying to achieve something that it seems very simple, but I can't make it work.

Example code:

static final Counter requests = Counter.build()
                    .namespace("sniffer")
                    .name("requests_total")
                    .labelNames("device","method","client","path","status")
                    .help("Total Requests.")
                    .register();
public void process(){
    //... some code
    requests.labels(device,httpMethod, client, path, status).inc();
}

I need to draw a graph with the total requests over time grouped by client.

So, I have the metric sniffer_requests_total, Which is the query that I have to build to achieve the graph I need?

I tried various queries on /graph console and I think I would need something like this:

rate(sniffer_requests_total[1m]) by (client) -> But this is an invalid query, because I can't use by with rate.

Upvotes: 0

Views: 2941

Answers (1)

brian-brazil
brian-brazil

Reputation: 34182

sum by (client)(rate(sniffer_requests_total[1m])

See Common query patterns in PromQL.

Upvotes: 2

Related Questions