I have an InfluxDB with a lot of Nagios data in it. For every 10 minutes I have information on how many users are logged in to a system at that time. I’m wondering if it’s possible to get the highest value per month somehow?
If I run:
SELECT mean("value") FROM "metrics" WHERE ("host" = 'SERVER' AND "performanceLabel" = 'Users') GROUP BY time(10m)
I get a list of all the values each 10 minutes, like this:
Hi, i have the same situation as above. But my result is a bit strange.
My database output data for probe “Test 1”:
time probe lastvalue_raw
2019-05-13T16:25:03Z Test 1
2019-05-13T20:00:03Z Test 1 862.8011
2019-05-14T00:00:02Z Test 1 873.1168
2019-05-14T04:00:02Z Test 1 879.2377
2019-05-14T08:00:03Z Test 1 887.7636
2019-05-14T12:00:02Z Test 1 895.3399
2019-05-14T16:00:03Z Test 1 909.3372
2019-05-14T20:00:03Z Test 1 920.6659
2019-05-15T00:00:02Z Test 1 933.2304
2019-05-15T04:00:03Z Test 1 940.0173
2019-05-15T08:00:03Z Test 1 953.7991
2019-05-15T12:00:03Z Test 1 963.5531
2019-05-15T16:00:02Z Test 1 974.5145
2019-05-15T20:00:03Z Test 1 989.7965
2019-05-16T00:00:03Z Test 1 1013.9998
2019-05-16T04:00:02Z Test 1 1004.0067
2019-05-16T08:00:02Z Test 1 1022.36
2019-05-16T12:00:02Z Test 1 1066.4328
My query:
SELECT max(lastvalue_raw) as lastvalue_raw FROM data_traffic WHERE (probe =~ /Test 1/ AND time >= now() - 52w) group by time(4w)
SELECT max(lastvalue_raw) as lastvalue_raw FROM data_traffic WHERE probe =~ /Test 1/ AND time >= ‘2018-05-16T00:00:00Z’ AND time <= ‘2019-05-16T13:00:00Z’ group by time(30d)
I believe it’s because of the combination of the time you selected and the groupby. Influx isn’t aware of months in the query you wrote. That April date with the value denotes the groupby that starts on 04/18 and groups data for the next 4 weeks. 4 weeks later on 05/15 you have a value of 989 so it is included in that group by. Instead, try using a start date at the beginning of the month. However, keep in mind that some months have more than 4 weeks (28 days), so this problem can still occur. Alternatively you can add the month in your tag.
@joschika77, you could include tags that specify the month at ingest. For example, I would write a python script that adds the months in tags based on the timestamp. You could also run 12 continuous queries for each month and output the max value into a new db. If you need to apply a CQ to historical data, you can backfill your old data by doing something similar to: Backfilling a Continuous Query?