How to get avg requests?

Grafana v6.0.1 (0c44a04)

Hello people!

Im currently trying to solve how I can get avg of total successful requests using Prometheus.

I have currently done something like:

sum(rate(scraper_request_count_total{store="$store_name", http_status=~"200|404|301"}[1m])) / sum(rate(scraper_request_count_total{store="$store_name"}[60m]))

scraper_request_count_total = is a prometheus label I have created myself:

REQUEST_COUNT = Counter(
    namespace="scraper",
    name="request_count",
    documentation="Count the total requests",
    labelnames=['store', 'http_status'],
)
                    rep = session.get(url, timeout=6)

                    # Collect data to prometheus
                    REQUEST_COUNT.labels(
                        store=STORE_NAME,
                        http_status=rep.status_code
                    ).inc()

What I am trying to do is that I want to get the avg per minute for 60 minutes and currently the data says I am avg 0.7 requests but checking the logs. During 30 sec. I can manually see I do reach over 30 successful requests. so the number should be alot higher and I do believe I am doing something wrong.

My quesiton is…

how can I get avg successful requests every 1 min for 60 minutes using Grafana?

@barryaljawari here is a great demo dashboard. I often inspect these panels for promql hints :+1:

https://play.grafana.org/d/000000029/prometheus-demo-dashboard?orgId=1&refresh=5m

1 Like