Skip to content

Instantly share code, notes, and snippets.

@ethaniel
Last active February 4, 2023 18:47
Show Gist options
  • Save ethaniel/970393e6c377fc16b0025f99b602881c to your computer and use it in GitHub Desktop.
Save ethaniel/970393e6c377fc16b0025f99b602881c to your computer and use it in GitHub Desktop.
Grafana: Highlight 12 hour intervals in graphs for easier viewing
  1. Open Grafana dashboard settings.
  2. Go to "Annotations"
  3. Create an annotation with a data source "InfluxDB" and add the following query:
import "array"
import "timezone"
import "date"

option location = timezone.location(name: "Asia/Bangkok")

array.from(rows:[
  {
    time_from: date.sub(d: 12h, from: today()),
    time: today(),
    text: "yesterday"
  },
  {
    time_from: date.add(d: 12h, to: today()),
    time: date.add(d: 24h, to: today()),
    text: "today"
  }
])
  1. Choose a prefered color (I chose the light blue color)
  2. Save the dashboard and reload it.
  3. Observe:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment