grafana/dashboard-schemas
Chris Trott 3d33de1751
dashboard-schemas cue 3.0.0 compatible (#29352)
Lead all top-level properties that we do not intend to export with an
underscore.

In 2.2.0, only definitions starting with a capital letter were exported.
As well, properties with a leading underscore were not visible to an
entire package - just within the same file. 3.0.0 still considers them
hidden, however, they are now visible to an entire package.
2020-11-25 07:43:09 +01:00
..
cue.mod
panels
targets
transformations
variables
Dashboard.cue
README.md

Dashboard Schemas

Schema description documents for Grafana Dashboard JSON and core panels.

Note: This directory is experimental. The schemas are not currently implemented or enforced in Grafana.

Schemas are defined in Cue. Cue was chosen because it strongly facilitates our primary use cases - schema definition, data validation, and code generation/extraction.

Schema Organization

Each schema describes part of a dashboard. Dashboard.cue is the main dashboard schema object. All other schemas describe nested objects within a dashboard. They are grouped in the following directories:

The following somewhat conveys how they fit together when constructing a dashboard:

+-----------+      +-----------+
| Dashboard +------> Variables |
+---------+-+      +-----------+
          |    +--------+    +---------+
          +----> Panels +----> Targets |
               +------+-+    +---------+
                      |      +-----------------+
                      +------> Transformations |
                             +-----------------+

Definitions

All schemas are Cue definitions. Schemas intended to be exported must begin with a capital letter. For example, Gauge. Definitions beginning with a lowercase letter will not be exported. These are reusable components for constructing the exported definitions. For example, #panel is intended to be a base schema for panels. #Gauge extends #panel with the following:

#Gauge: panel & {
	...
}

Exporting OpenAPI

OpenAPI schemas can be exported from these CUE sources. Use the cue command as follows, to generate OpenAPI JSON to stdout:

cue export --out openapi -o - ./dashboard-schemas/...