Managing Grafana Dashboards With grafonnet and git Adam Wolfe - - PowerPoint PPT Presentation

managing grafana dashboards with grafonnet and git
SMART_READER_LITE
LIVE PREVIEW

Managing Grafana Dashboards With grafonnet and git Adam Wolfe - - PowerPoint PPT Presentation

Managing Grafana Dashboards With grafonnet and git Adam Wolfe Gordon DigitalOcean PromCon 2019 Munich digitalocean.com How many of you use Grafana? digitalocean.com Is Grafana important to you? digitalocean.com How many of you do code


slide-1
SLIDE 1

digitalocean.com

Managing Grafana Dashboards With grafonnet and git

Adam Wolfe Gordon DigitalOcean PromCon 2019 Munich

slide-2
SLIDE 2

digitalocean.com

How many of you use Grafana?

slide-3
SLIDE 3

digitalocean.com

Is Grafana important to you?

slide-4
SLIDE 4

digitalocean.com

How many of you do code review?

For your application/service/whatever?

slide-5
SLIDE 5

digitalocean.com

How many of you run CI tests? How many do some kind of CD?

For your application/service/whatever?

slide-6
SLIDE 6

digitalocean.com

How many of you do code review CI testing continuous deployment

  • n your Grafana dashboards?
slide-7
SLIDE 7

digitalocean.com

We should!

  • Grafana dashboards are important.
  • We should apply good engineering practices.

○ Version control ○ Code review ○ Continuous integration and deployment ○ Component re-use

slide-8
SLIDE 8

digitalocean.com

How?

  • Grafana has an API - so this should be easy.
  • But:

○ Grafana’s JSON model isn’t pretty. ○ Dashboards are inherently visual - hard to test/verify.

slide-9
SLIDE 9

digitalocean.com

Solution 1 jsonnet and grafonnet

local grafana = import 'grafonnet/grafana.libsonnet'; local dashboard = grafana.dashboard; dashboard.new('My Cool Dashboard')

  • jsonnet: JSON templating language.
  • grafonnet: Grafana jsonnet library.
  • Human-friendly.
  • Allows for libraries.

{ "__inputs": [ ], "__requires": [ ], "annotations": { "list": [ ] }, "editable": false, "gnetId": null, "graphTooltip": 0, "hideControls": false, "id": null, "links": [ ], "refresh": "", "rows": [ ], "schemaVersion": 14, "style": "dark", "tags": [ ], "templating": { "list": [ ] }, "time": { "from": "now-6h", "to": "now" }, "timepicker": { "refresh_intervals": [ "5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d" ], "time_options": [ "5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d" ] }, "timezone": "browser", "title": "My Cool Dashboard", "version": 0 }

slide-10
SLIDE 10

digitalocean.com

Solution 2 Grafana’s Snapshot API

  • Grafana can create snapshots.

○ Point-in-time copy of a dashboard. ○ Immutable.

  • Not only for existing dashboards!

local grafana = import 'grafonnet/grafana.libsonnet'; local dashboard = grafana.dashboard; local text = grafana.text; dashboard.new('My Cool Dashboard') .addPanel( text.new( title="Oh Hi", content="Welcome to my dashboard.", ), gridPos={x: 0, y: 0, w: 24, h: 10}, )

slide-11
SLIDE 11

digitalocean.com

Putting Together the Pieces

  • git repository of jsonnet dashboard definitions.
  • Script to generate previews.
  • CI job to find changes and run the script.
  • CD job to publish dashboards on merge.
slide-12
SLIDE 12

digitalocean.com

Demo Time!

https://github.com/adamwg/grafana-dashboards

slide-13
SLIDE 13

Questions?

Adam Wolfe Gordon awg@do.co https://github.com/adamwg/grafana-dashboards

slide-14
SLIDE 14