In which timestamp was the maximum per day for week of data

Is there a way I can select a timestamp with maximum value per day per week of data?
What I can actually get is timestamp of 00:00:00
2020-01-21T00:00:00Z 4.722222222222222
2020-01-20T00:00:00Z 4.722222222222222
2020-01-19T00:00:00Z 4.611111111111111
2020-01-18T00:00:00Z 4.611111111111111

but I would like to have the exact time of the maximum value, e.g.
2020-01-21T04:00:00Z 4.722222222222222
2020-01-20T08:00:00Z 4.722222222222222
2020-01-19T02:00:00Z 4.611111111111111
2020-01-18T09:00:00Z 4.611111111111111

Hello @jkr,
Are you using Flux or Influxql? I suggest using v2.0 with Flux. With Flux you have _start, _stop, and _time. _time provides the actual timestamp. Take a look at the spec to understand more.
I think I would do something like:

  |> range(start: -7d)
  |> filter(fn: (r) => r._field == "usage_user")
  |> filter(fn: (r) => r.cpu =="cpu-total")
  |> window(every: 1d, period: 1d, timeColumn: "_time", startColumn: "_start", stopColumn: "_stop")
  |> max()
  |> group()

Hi @Anaisdg,
thank you for the answer, unfortunatelly v2.0 is still in beta and is not recommended for production usage.

@jkr Flux is available with InfluxDB 1.7, you just need to enable it:

1 Like