Influx queery - requests success rate

Suppose I have such data in Influxdb (number of requests per service/response_code, values are counters, not number of requests per second):

time response_code service value


1501589701418000000 200 details 34
1501589701418000000 500 details 2
1501589701418000000 200 productpage 33
1501589701418000000 500 productpage 2

I’d like to get ‘success rate’, so number of successful requests (RC==200) divided by number of all requests. I’d like to get a graph of such success rate in grafana (f.e. every 10 seconds).

Is it possible to get it in Influx? I have trouble to create such query (is it possible to divide values from two 'subqueries?)

I’m not completely clear about your measurement Schema. But I think it is quite possible using a query like below:

  1. Select the sum of Response_codes
  2. Divide it by each value

select value/sum from (sum (value) from where time >= 123456s group by time(10s) where time >= 123456s group by time(10s),Response_code

Hi, Thanks.
I cannot make it working.

Real data:

When I run:
select DERIVATIVE(sum(value),10s) as all from request_count where time >= ‘2017-08-02T10:17:00Z’ AND time <= ‘2017-08-02T10:19:00Z’ GROUP BY time(10s) fill(null)

I get:
time derivative


2017-08-02T10:17:00Z 0
2017-08-02T10:17:10Z 0
2017-08-02T10:17:20Z 0
2017-08-02T10:17:30Z 0
2017-08-02T10:17:40Z 0
2017-08-02T10:17:50Z 0
2017-08-02T10:18:00Z 4
2017-08-02T10:18:10Z 58
2017-08-02T10:18:20Z 147
2017-08-02T10:18:30Z 330
2017-08-02T10:18:40Z 11
2017-08-02T10:18:50Z 0

select DERIVATIVE(sum(value),10s) from request_count where response_code=‘200’ AND time >= ‘2017-08-02T10:17:00Z’ AND time <= ‘2017-08-02T10:19:00Z’ GROUP BY time(10s) fill(null)
name: request_count
time derivative


2017-08-02T10:17:00Z 0
2017-08-02T10:17:10Z 0
2017-08-02T10:17:20Z 0
2017-08-02T10:17:30Z 0
2017-08-02T10:17:40Z 0
2017-08-02T10:17:50Z 0
2017-08-02T10:18:00Z 4
2017-08-02T10:18:10Z 58
2017-08-02T10:18:20Z 147
2017-08-02T10:18:30Z 315
2017-08-02T10:18:40Z 11
2017-08-02T10:18:50Z 0

And I would like to get:


2017-08-02T10:17:00Z 1
2017-08-02T10:17:10Z 1
2017-08-02T10:17:20Z 1
2017-08-02T10:17:30Z 1
2017-08-02T10:17:40Z 1
2017-08-02T10:17:50Z 1
2017-08-02T10:18:00Z 1
2017-08-02T10:18:10Z 1
2017-08-02T10:18:20Z 1
2017-08-02T10:18:30Z 0.95
2017-08-02T10:18:40Z 1
2017-08-02T10:18:50Z 1

Can you try the following:

select value/sum from (sum(value) from request_count where time >= ‘2017-08-02T10:17:00Z’ AND time <= ‘2017-08-02T10:19:00Z’ GROUP BY time(10s)) where response_code=200 and time >= ‘2017-08-02T10:17:00Z’ AND time <= ‘2017-08-02T10:19:00Z’ GROUP BY time(10s)

The above should give you the data for “response_code=200” (ratio of success)

If you would like to see it for all the response codes:

select value/sum from (sum(value) from request_count where time >= ‘2017-08-02T10:17:00Z’ AND time <= ‘2017-08-02T10:19:00Z’ GROUP BY time(10s)) where time >= ‘2017-08-02T10:17:00Z’ AND time <= ‘2017-08-02T10:19:00Z’ GROUP BY time(10s),response_code

thanks @sbains
finally I did it with kapacitor (aggregate some metrics in it and push it to another measurement info influx)

Hello,
I have similar question.
I’m not sure if this is a feature request or if this kind of functionality already exists.
I looked at #3976 and #4081 (influxdb github).

First what I’m trying to accomplish: create a dashboard in chronograf showing different groupings of requests/s hitting our servers. I’m using SELECT sum("count") / 60 AS "requests per second" FROM "mydb"."autogen"."queries" WHERE time > :dashboardTime: GROUP BY time(1m), "server" FILL(0).

However this query gets slower and slower when showing large timespans because it returns data with 1 second (or lower) resolution. Usually in queries there is GROUP BY :interval: but it cannot be used here for some reason.

My question is, can I somehow use :interval: template variable to group data again for the display?