|
| 1 | +package grafanaschema |
| 2 | + |
| 3 | +import "github.com/grafana/grafana/cue/scuemata" |
| 4 | + |
| 5 | +Family: scuemata.#Family & { |
| 6 | + lineages: [ |
| 7 | + [ |
| 8 | + { // 0.0 |
| 9 | + // Unique numeric identifier for the dashboard. |
| 10 | + // TODO must isolate or remove identifiers local to a Grafana instance...? |
| 11 | + id?: number |
| 12 | + // Unique dashboard identifier that can be generated by anyone. string (8-40) |
| 13 | + uid: string |
| 14 | + // Title of dashboard. |
| 15 | + title?: string |
| 16 | + // Description of dashboard. |
| 17 | + description?: string |
| 18 | + |
| 19 | + gnetId?: string |
| 20 | + // Tags associated with dashboard. |
| 21 | + tags?: [...string] |
| 22 | + // Theme of dashboard. |
| 23 | + style: *"light" | "dark" |
| 24 | + // Timezone of dashboard, |
| 25 | + timezone?: *"browser" | "utc" |
| 26 | + // Whether a dashboard is editable or not. |
| 27 | + editable: bool | *true |
| 28 | + // 0 for no shared crosshair or tooltip (default). |
| 29 | + // 1 for shared crosshair. |
| 30 | + // 2 for shared crosshair AND shared tooltip. |
| 31 | + graphTooltip: >=0 & <=2 | *0 |
| 32 | + // Time range for dashboard, e.g. last 6 hours, last 7 days, etc |
| 33 | + time?: { |
| 34 | + from: string | *"now-6h" |
| 35 | + to: string | *"now" |
| 36 | + } |
| 37 | + // Timepicker metadata. |
| 38 | + timepicker?: { |
| 39 | + // Whether timepicker is collapsed or not. |
| 40 | + collapse: bool | *false |
| 41 | + // Whether timepicker is enabled or not. |
| 42 | + enable: bool | *true |
| 43 | + // Whether timepicker is visible or not. |
| 44 | + hidden: bool | *false |
| 45 | + // Selectable intervals for auto-refresh. |
| 46 | + refresh_intervals: [...string] | *["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"] |
| 47 | + } |
| 48 | + // Templating. |
| 49 | + templating?: list: [...{...}] |
| 50 | + // Annotations. |
| 51 | + annotations?: list: [...{ |
| 52 | + builtIn: number | *0 |
| 53 | + // Datasource to use for annotation. |
| 54 | + datasource: string |
| 55 | + // Whether annotation is enabled. |
| 56 | + enable?: bool | *true |
| 57 | + // Whether to hide annotation. |
| 58 | + hide?: bool | *false |
| 59 | + // Annotation icon color. |
| 60 | + iconColor?: string |
| 61 | + // Name of annotation. |
| 62 | + name?: string |
| 63 | + type: string | *"dashboard" |
| 64 | + // Query for annotation data. |
| 65 | + rawQuery?: string |
| 66 | + showIn: number | *0 |
| 67 | + }] |
| 68 | + // Auto-refresh interval. |
| 69 | + refresh?: string |
| 70 | + // Version of the JSON schema, incremented each time a Grafana update brings |
| 71 | + // changes to said schema. |
| 72 | + schemaVersion: number | *25 |
| 73 | + // Version of the dashboard, incremented each time the dashboard is updated. |
| 74 | + version?: number |
| 75 | + panels?: [...#Panel] |
| 76 | + |
| 77 | + // Dashboard panels. Panels are canonically defined inline |
| 78 | + // because they share a version timeline with the dashboard |
| 79 | + // schema; they do not vary independently. We create a separate, |
| 80 | + // synthetic Family to represent them in Go, for ease of generating |
| 81 | + // e.g. JSON Schema. |
| 82 | + #Panel: { |
| 83 | + // The panel plugin type id. |
| 84 | + type: !="" |
| 85 | + |
| 86 | + // Internal - the exact major and minor versions of the panel plugin |
| 87 | + // schema. Hidden and therefore not a part of the data model, but |
| 88 | + // expected to be filled with panel plugin schema versions so that it's |
| 89 | + // possible to figure out which schema version matched on a successful |
| 90 | + // unification. |
| 91 | + // _pv: { maj: int, min: int } |
| 92 | + // The major and minor versions of the panel plugin for this schema. |
| 93 | + // TODO 2-tuple list instead of struct? |
| 94 | + panelSchema: { maj: number, min: number } |
| 95 | + |
| 96 | + // Panel title. |
| 97 | + title?: string |
| 98 | + // Description. |
| 99 | + description?: string |
| 100 | + // Whether to display the panel without a background. |
| 101 | + transparent: bool | *false |
| 102 | + // Name of default datasource. |
| 103 | + datasource?: string |
| 104 | + // Grid position. |
| 105 | + gridPos?: { |
| 106 | + // Panel |
| 107 | + h: number & >0 | *9 |
| 108 | + // Panel |
| 109 | + w: number & >0 & <=24 | *12 |
| 110 | + // Panel x |
| 111 | + x: number & >=0 & <24 | *0 |
| 112 | + // Panel y |
| 113 | + y: number & >=0 | *0 |
| 114 | + // true if fixed |
| 115 | + static?: bool |
| 116 | + } |
| 117 | + // Panel links. |
| 118 | + // links?: [..._panelLink] |
| 119 | + // Name of template variable to repeat for. |
| 120 | + repeat?: string |
| 121 | + // Direction to repeat in if 'repeat' is set. |
| 122 | + // "h" for horizontal, "v" for vertical. |
| 123 | + repeatDirection: *"h" | "v" |
| 124 | + // Schema for panel targets is specified by datasource |
| 125 | + // plugins. We use a placeholder definition, which the Go |
| 126 | + // schema loader either left open/as-is with the Base |
| 127 | + // variant of the Dashboard and Panel families, or filled |
| 128 | + // with types derived from plugins in the Instance variant. |
| 129 | + // When working directly from CUE, importers can extend this |
| 130 | + // type directly to achieve the same effect. |
| 131 | + targets?: [...{}] |
| 132 | + |
| 133 | + // The values depend on panel type |
| 134 | + options: {...} |
| 135 | + |
| 136 | + fieldConfig: { |
| 137 | + defaults: { |
| 138 | + // The display value for this field. This supports template variables blank is auto |
| 139 | + displayName?: string |
| 140 | + |
| 141 | + // This can be used by data sources that return and explicit naming structure for values and labels |
| 142 | + // When this property is configured, this value is used rather than the default naming strategy. |
| 143 | + displayNameFromDS?: string |
| 144 | + |
| 145 | + // Human readable field metadata |
| 146 | + description?: string |
| 147 | + |
| 148 | + // An explict path to the field in the datasource. When the frame meta includes a path, |
| 149 | + // This will default to `${frame.meta.path}/${field.name} |
| 150 | + // |
| 151 | + // When defined, this value can be used as an identifier within the datasource scope, and |
| 152 | + // may be used to update the results |
| 153 | + path?: string |
| 154 | + |
| 155 | + // True if data source can write a value to the path. Auth/authz are supported separately |
| 156 | + writeable?: bool |
| 157 | + |
| 158 | + // True if data source field supports ad-hoc filters |
| 159 | + filterable?: bool |
| 160 | + |
| 161 | + // Numeric Options |
| 162 | + unit?: string |
| 163 | + |
| 164 | + // Significant digits (for display) |
| 165 | + decimals?: number |
| 166 | + |
| 167 | + min?: number |
| 168 | + max?: number |
| 169 | + |
| 170 | + // // Convert input values into a display string |
| 171 | + // mappings?: ValueMapping[]; |
| 172 | + |
| 173 | + // // Map numeric values to states |
| 174 | + // thresholds?: ThresholdsConfig; |
| 175 | + |
| 176 | + // // Map values to a display color |
| 177 | + // color?: FieldColor; |
| 178 | + |
| 179 | + // // Used when reducing field values |
| 180 | + // nullValueMode?: NullValueMode; |
| 181 | + |
| 182 | + // // The behavior when clicking on a result |
| 183 | + // links?: DataLink[]; |
| 184 | + |
| 185 | + // Alternative to empty string |
| 186 | + noValue?: string |
| 187 | + |
| 188 | + // Can always exist. Valid fields within this are |
| 189 | + // defined by the panel plugin - that's the |
| 190 | + // PanelFieldConfig that comes from the plugin. |
| 191 | + custom?: {...} |
| 192 | + } |
| 193 | + overrides: [...{ |
| 194 | + matcher: { |
| 195 | + id: string | *"" |
| 196 | + options?: _ |
| 197 | + } |
| 198 | + properties: [...{ |
| 199 | + id: string | *"" |
| 200 | + value?: _ |
| 201 | + }] |
| 202 | + }] |
| 203 | + } |
| 204 | + } |
| 205 | + } |
| 206 | + ] |
| 207 | + ] |
| 208 | +} |
| 209 | + |
| 210 | +#Latest: { |
| 211 | + #Dashboard: Family.latest |
| 212 | + #Panel: Family.latest._Panel |
| 213 | +} |
0 commit comments