How do I have to change this Flux query to get values at 00:00 instead of 01:00?

annotations are off by 1h

I’m trying to add annotations to a time series graph in Grafana. I’m getting the annotation values with the following Flux query from InfluxDB:

import "strings"

from(bucket: "vevantzedata")
 |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
 |> filter(fn: (r) => r["_measurement"] == "pops")
 |> filter(fn: (r) => r["_field"] =~ /^(cycle|cycle_day)/)
 |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
 |> map(fn: (r) => ({r with label: strings.joinStr(arr: [string(v: r["cycle"]), string(v: r["cycle_day"])], v: "-")}))
 |> window(every: 1d)
 |> duplicate(column: "_stop", as: "_time")

My goal is to have one annotation per day, positioned exactly at midnight (00:00). My problem is that the positioning is off by 1h. They show up at exactly 01:00 instead of 01:00. What’s wrong with my query?

Hello @thundersen,
What is your v.timeRangeStop equal to?
You might consider:

  1. including an offset
window(
  every: 1d,
  offset: -1h,
  timeColumn: "_time",
  startColumn: "_start",
  stopColumn: "_stop",
  location: "UTC",
  createEmpty: false
)
  1. today() function | Flux 0.x Documentation
    in your range

  2. OR if I’m misunderstanding something timeShift()
    timeShift() function | Flux 0.x Documentation
    ** keep in mind you might want to only shift some columns and not all of them so that your windowing is as expected