Clark Boylan 9f77874ae8 Use copies of data when creating datasources
The datasource creation process modifies its input data to set a uid
value on the datasource blob. Under normal operation this is fine as we
don't expect hardcoded uid values, but in testing we may use fake data
that includes uid values. In these test cases if creation was performed
before other test cases the uid value could be modified in place
breaking later test cases.

To avoid confusion and keep testing simple we update the create method
to operate on a copy of the input data before it modifies that
dictionary.

Change-Id: I6ae077d265f7efdf37676f3b0c131d9ad65e9963
2026-07-30 16:45:16 -07:00
2020-06-25 15:04:14 +10:00
2019-04-19 19:26:03 +00:00
2015-05-04 13:14:07 -04:00
2023-09-19 11:06:17 -07:00
2015-05-04 13:14:07 -04:00
2015-05-04 13:14:07 -04:00
2015-05-04 13:14:07 -04:00
2015-05-04 13:14:07 -04:00
2015-05-04 13:14:07 -04:00
2020-06-25 15:04:14 +10:00
2020-06-24 11:52:23 +10:00

grafyaml

At a glance

Overview

grafyaml takes descriptions of Grafana dashboards in YAML format, and uses them to produce JSON formatted output suitable for direct import into Grafana.

The tool uses the Voluptuous data validation library to ensure the input produces a valid dashboard. Along with validation, users receive the benefits of YAML markup such as comments and clearer type support.

For example, here is a minimal dashboard specification

dashboard:
  time:
    from: "2018-02-07T08:42:27.000Z"
    to: "2018-02-07T13:48:32.000Z"
  templating:
    - name: hostname
      type: query
      datasource: graphite
      query: node*
      refresh: true
  title: My great dashboard
  rows:
    - title: CPU Usage
      height: 250px
      panels:
          - title: CPU Usage for $hostname
            type: graph
            datasource: graphite
            targets:
              - target: $hostname.Cpu.cpu_prct_used

grafyaml can be very useful in continuous-integration environments. Users can specify their dashboards via a normal review process and tests can validate their correctness.

The tool can also take JSON manually exported from the Grafana interface and load it as a dashboard. This allows keeping dashboards that have been edited with the inbuilt editor externally version controlled.

A large number of examples are available in the OpenStack project-config repository, which are used to create dashboards on http://grafana.openstack.org.

S
Description
Tools to make Grafana dashboards from templates
Readme
1.4 MiB
Languages
Python 99%
Dockerfile 1%