Calculate % based on data (Influxdb 1.2)


Very new to influxdb and I am struggling to find a solution to what I guess should be simple (think its a user issue :))

Imagine i have the following data within a 5 second period

2017-04-20T12:40:53.258387846Z false
2017-04-20T12:40:54.230486362Z false
2017-04-20T12:40:55.298014724Z false
2017-04-20T12:40:56.150790768Z false
2017-04-20T12:41:06.05425819Z false
2017-04-20T12:41:06.73383734Z true
2017-04-20T12:41:07.383999348Z true
2017-04-20T12:41:07.901710265Z true
2017-04-20T12:41:08.334062383Z true
2017-04-20T12:44:08.334062383Z true

10 items , 5 true and 5 false, how can I show this as the following

Start Time, Total Number, Success rate
2017-04-20T12:40:53.258387846Z, 10, 50%


I think there are two ways to solve this issue:

  1. Using Nested statements: e.g.

The count on the field gives you the number of “items” and you can write a nested statement to find the count of “true” fields and calculate the percentage on it.

  1. Using Boolean field as integer - or set true = 1 and false = 0 (so you can perform numerical operation on the field values)

In this case you can simply perform the percentage calculation in a single statement:

( count(field) / sum(field)) * 100