Schema: Improve Dashboard kind docs and remove deprecated props (#69359)

Remove unused properties: 
  * `FieldColorModeId.PaletteSaturated`: It doesn't exist and it is not a valid palette.
  * `VariableModel.rootStateKey`: It is not persisted in the DB, so it shouldn't be in the schema. It is a property only used in the frontend to store the Redux store key.
  * `VariableModel.error`: It is not persisted in the DB, so it shouldn't be in the schema. It is a property only used in the frontend to store fetching errors.
  * `Panel.thresholds`: old property only existing in previous versions of the dashboard schema.
  * `Panel.timeRegions`: old property only existing in previous versions of the dashboard schema.
This commit is contained in:
Ivan Ortega Alba 2023-06-06 14:28:10 +02:00 committed by GitHub
parent ae0f94e616
commit 819041c732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1422 additions and 806 deletions

View File

@ -864,7 +864,7 @@ exports[`better eslint`] = {
"packages/grafana-schema/src/veneer/dashboard.types.ts:5381": [ "packages/grafana-schema/src/veneer/dashboard.types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"], [0, 0, 0, "Do not use any type assertions.", "5"],

View File

@ -64,40 +64,43 @@ extraFields is reserved for any fields that are pulled from the API server metad
### Spec ### Spec
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|------------------------|---------------------------------------------|----------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |------------------------|---------------------------------------------|----------|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `editable` | boolean | **Yes** | `true` | Whether a dashboard is editable or not. | | `editable` | boolean | **Yes** | `true` | Whether a dashboard is editable or not. |
| `graphTooltip` | integer | **Yes** | `0` | 0 for no shared crosshair or tooltip (default).<br/>1 for shared crosshair.<br/>2 for shared crosshair AND shared tooltip.<br/>Possible values are: `0`, `1`, `2`. | | `graphTooltip` | integer | **Yes** | `0` | 0 for no shared crosshair or tooltip (default).<br/>1 for shared crosshair.<br/>2 for shared crosshair AND shared tooltip.<br/>Possible values are: `0`, `1`, `2`. |
| `schemaVersion` | uint16 | **Yes** | `36` | Version of the JSON schema, incremented each time a Grafana update brings<br/>changes to said schema.<br/>TODO this is the existing schema numbering system. It will be replaced by Thema's themaVersion | | `schemaVersion` | uint16 | **Yes** | `36` | Version of the JSON schema, incremented each time a Grafana update brings<br/>changes to said schema. |
| `style` | string | **Yes** | `dark` | Theme of dashboard.<br/>Possible values are: `dark`, `light`. | | `style` | string | **Yes** | `dark` | Theme of dashboard.<br/>Default value: dark.<br/>Possible values are: `dark`, `light`. |
| `annotations` | [AnnotationContainer](#annotationcontainer) | No | | TODO -- should not be a public interface on its own, but required for Veneer | | `annotations` | [AnnotationContainer](#annotationcontainer) | No | | Contains the list of annotations that are associated with the dashboard.<br/>Annotations are used to overlay event markers and overlay event tags on graphs.<br/>Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.<br/>See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/ |
| `description` | string | No | | Description of dashboard. | | `description` | string | No | | Description of dashboard. |
| `fiscalYearStartMonth` | integer | No | `0` | The month that the fiscal year starts on. 0 = January, 11 = December<br/>Constraint: `>=0 & <12`. | | `fiscalYearStartMonth` | integer | No | `0` | The month that the fiscal year starts on. 0 = January, 11 = December<br/>Constraint: `>=0 & <12`. |
| `gnetId` | string | No | | ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal | | `gnetId` | string | No | | ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal |
| `id` | integer | No | | Unique numeric identifier for the dashboard.<br/>TODO must isolate or remove identifiers local to a Grafana instance...? | | `id` | integer | No | | Unique numeric identifier for the dashboard.<br/>`id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances. |
| `links` | [DashboardLink](#dashboardlink)[] | No | | Links with references to other dashboards or external websites. | | `links` | [DashboardLink](#dashboardlink)[] | No | | Links with references to other dashboards or external websites. |
| `liveNow` | boolean | No | | When set to true, the dashboard will redraw panels at an interval matching the pixel width.<br/>This will keep data "moving left" regardless of the query refresh rate. This setting helps<br/>avoid dashboards presenting stale live data | | `liveNow` | boolean | No | | When set to true, the dashboard will redraw panels at an interval matching the pixel width.<br/>This will keep data "moving left" regardless of the query refresh rate. This setting helps<br/>avoid dashboards presenting stale live data |
| `panels` | [object](#panels)[] | No | | | | `panels` | [object](#panels)[] | No | | List of dashboard panels |
| `refresh` | | No | | Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". | | `refresh` | | No | | Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". |
| `revision` | integer | No | | This property should only be used in dashboards defined by plugins. It is a quick check<br/>to see if the version has changed since the last time. Unclear why using the version property<br/>is insufficient. | | `revision` | integer | No | | This property should only be used in dashboards defined by plugins. It is a quick check<br/>to see if the version has changed since the last time. |
| `snapshot` | [Snapshot](#snapshot) | No | | A dashboard snapshot shares an interactive dashboard publicly.<br/>It is a read-only version of a dashboard, and is not editable.<br/>It is possible to create a snapshot of a snapshot.<br/>Grafana strips away all sensitive information from the dashboard.<br/>Sensitive information stripped: queries (metric, template,annotation) and panel links. | | `snapshot` | [Snapshot](#snapshot) | No | | A dashboard snapshot shares an interactive dashboard publicly.<br/>It is a read-only version of a dashboard, and is not editable.<br/>It is possible to create a snapshot of a snapshot.<br/>Grafana strips away all sensitive information from the dashboard.<br/>Sensitive information stripped: queries (metric, template,annotation) and panel links. |
| `tags` | string[] | No | | Tags associated with dashboard. | | `tags` | string[] | No | | Tags associated with dashboard. |
| `templating` | [object](#templating) | No | | Contains the list of configured template variables with their saved values along with some other metadata | | `templating` | [object](#templating) | No | | Configured template variables |
| `time` | [object](#time) | No | | Time range for dashboard.<br/>Accepted values are relative time strings like {from: 'now-6h', to: 'now'} or absolute time strings like {from: '2020-07-10T08:00:00.000Z', to: '2020-07-10T14:00:00.000Z'}. | | `time` | [object](#time) | No | | Time range for dashboard.<br/>Accepted values are relative time strings like {from: 'now-6h', to: 'now'} or absolute time strings like {from: '2020-07-10T08:00:00.000Z', to: '2020-07-10T14:00:00.000Z'}. |
| `timepicker` | [object](#timepicker) | No | | Configuration of the time picker shown at the top of a dashboard. | | `timepicker` | [object](#timepicker) | No | | Configuration of the time picker shown at the top of a dashboard. |
| `timezone` | string | No | `browser` | Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc". | | `timezone` | string | No | `browser` | Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc". |
| `title` | string | No | | Title of dashboard. | | `title` | string | No | | Title of dashboard. |
| `uid` | string | No | | Unique dashboard identifier that can be generated by anyone. string (8-40) | | `uid` | string | No | | Unique dashboard identifier that can be generated by anyone. string (8-40) |
| `version` | uint32 | No | | Version of the dashboard, incremented each time the dashboard is updated. | | `version` | uint32 | No | | Version of the dashboard, incremented each time the dashboard is updated. |
| `weekStart` | string | No | | Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday". | | `weekStart` | string | No | | Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday". |
### AnnotationContainer ### AnnotationContainer
TODO -- should not be a public interface on its own, but required for Veneer Contains the list of annotations that are associated with the dashboard.
Annotations are used to overlay event markers and overlay event tags on graphs.
Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------|---------------------------------------|----------|---------|-------------| |----------|---------------------------------------|----------|---------|---------------------|
| `list` | [AnnotationQuery](#annotationquery)[] | No | | | | `list` | [AnnotationQuery](#annotationquery)[] | No | | List of annotations |
### AnnotationQuery ### AnnotationQuery
@ -190,78 +193,91 @@ Sensitive information stripped: queries (metric, template,annotation) and panel
### DataTransformerConfig ### DataTransformerConfig
TODO docs Transformations allow to manipulate data returned by a query before the system applies a visualization.
Using transformations you can: rename fields, join time series data, perform mathematical operations across queries,
use the output of one transformation as the input to another transformation, etc.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|------------|---------------------------------|----------|---------|----------------------------------------------------------------------------------------| |------------|---------------------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | string | **Yes** | | Unique identifier of transformer | | `id` | string | **Yes** | | Unique identifier of transformer |
| `options` | | **Yes** | | Options to be passed to the transformer<br/>Valid options depend on the transformer id | | `options` | | **Yes** | | Options to be passed to the transformer<br/>Valid options depend on the transformer id |
| `disabled` | boolean | No | | Disabled transformations are skipped | | `disabled` | boolean | No | | Disabled transformations are skipped |
| `filter` | [MatcherConfig](#matcherconfig) | No | | | | `filter` | [MatcherConfig](#matcherconfig) | No | | Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.<br/>It comes with in id ( to resolve implementation from registry) and a configuration thats specific to a particular matcher type. |
### MatcherConfig ### MatcherConfig
| Property | Type | Required | Default | Description | Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
|-----------|--------|----------|---------|-------------| It comes with in id ( to resolve implementation from registry) and a configuration thats specific to a particular matcher type.
| `id` | string | **Yes** | `` | |
| `options` | | No | | | | Property | Type | Required | Default | Description |
|-----------|--------|----------|---------|--------------------------------------------------------------------------------|
| `id` | string | **Yes** | `` | The matcher id. This is used to find the matcher implementation from registry. |
| `options` | | No | | The matcher options. This is specific to the matcher implementation. |
### FieldConfigSource ### FieldConfigSource
| Property | Type | Required | Default | Description | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|-------------|-----------------------------|----------|---------|-------------| Each column within this structure is called a field. A field can represent a single time series or table column.
| `defaults` | [FieldConfig](#fieldconfig) | **Yes** | | | Field options allow you to change how the data is displayed in your visualizations.
| `overrides` | [object](#overrides)[] | **Yes** | | |
| Property | Type | Required | Default | Description |
|-------------|-----------------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `defaults` | [FieldConfig](#fieldconfig) | **Yes** | | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.<br/>Each column within this structure is called a field. A field can represent a single time series or table column.<br/>Field options allow you to change how the data is displayed in your visualizations. |
| `overrides` | [object](#overrides)[] | **Yes** | | Overrides are the options applied to specific fields overriding the defaults. |
### FieldConfig ### FieldConfig
| Property | Type | Required | Default | Description | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|---------------------|---------------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Each column within this structure is called a field. A field can represent a single time series or table column.
| `color` | [FieldColor](#fieldcolor) | No | | TODO docs | Field options allow you to change how the data is displayed in your visualizations.
| `custom` | [object](#custom) | No | | custom is specified by the FieldConfig field<br/>in panel plugin schemas. |
| `decimals` | number | No | | Significant digits (for display) | | Property | Type | Required | Default | Description |
| `description` | string | No | | Human readable field metadata | |---------------------|---------------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `displayNameFromDS` | string | No | | This can be used by data sources that return and explicit naming structure for values and labels<br/>When this property is configured, this value is used rather than the default naming strategy. | | `color` | [FieldColor](#fieldcolor) | No | | Map a field to a color. |
| `displayName` | string | No | | The display value for this field. This supports template variables blank is auto | | `custom` | [object](#custom) | No | | custom is specified by the FieldConfig field<br/>in panel plugin schemas. |
| `filterable` | boolean | No | | True if data source field supports ad-hoc filters | | `decimals` | number | No | | Specify the number of decimals Grafana includes in the rendered value.<br/>If you leave this field blank, Grafana automatically truncates the number of decimals based on the value.<br/>For example 1.1234 will display as 1.12 and 100.456 will display as 100.<br/>To display all decimals, set the unit to `String`. |
| `links` | | No | | The behavior when clicking on a result | | `description` | string | No | | Human readable field metadata |
| `mappings` | [ValueMapping](#valuemapping)[] | No | | Convert input values into a display string | | `displayNameFromDS` | string | No | | This can be used by data sources that return and explicit naming structure for values and labels<br/>When this property is configured, this value is used rather than the default naming strategy. |
| `max` | number | No | | | | `displayName` | string | No | | The display value for this field. This supports template variables blank is auto |
| `min` | number | No | | | | `filterable` | boolean | No | | True if data source field supports ad-hoc filters |
| `noValue` | string | No | | Alternative to empty string | | `links` | | No | | The behavior when clicking on a result |
| `path` | string | No | | An explicit path to the field in the datasource. When the frame meta includes a path,<br/>This will default to `${frame.meta.path}/${field.name}<br/><br/>When defined, this value can be used as an identifier within the datasource scope, and<br/>may be used to update the results | | `mappings` | [ValueMapping](#valuemapping)[] | No | | Convert input values into a display string |
| `thresholds` | [ThresholdsConfig](#thresholdsconfig) | No | | | | `max` | number | No | | The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. |
| `unit` | string | No | | Numeric Options | | `min` | number | No | | The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. |
| `writeable` | boolean | No | | True if data source can write a value to the path. Auth/authz are supported separately | | `noValue` | string | No | | Alternative to empty string |
| `path` | string | No | | An explicit path to the field in the datasource. When the frame meta includes a path,<br/>This will default to `${frame.meta.path}/${field.name}<br/><br/>When defined, this value can be used as an identifier within the datasource scope, and<br/>may be used to update the results |
| `thresholds` | [ThresholdsConfig](#thresholdsconfig) | No | | Thresholds configuration for the panel |
| `unit` | string | No | | Unit a field should use. The unit you select is applied to all fields except time.<br/>You can use the units ID availables in Grafana or a custom unit.<br/>Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts<br/>As custom unit, you can use the following formats:<br/>`suffix:<suffix>` for custom unit that should go after value.<br/>`prefix:<prefix>` for custom unit that should go before value.<br/>`time:<format>` For custom date time formats type for example `time:YYYY-MM-DD`.<br/>`si:<base scale><unit characters>` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character.<br/>`count:<unit>` for a custom count unit.<br/>`currency:<unit>` for custom a currency unit. |
| `writeable` | boolean | No | | True if data source can write a value to the path. Auth/authz are supported separately |
### FieldColor ### FieldColor
TODO docs Map a field to a color.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|--------------|--------|----------|---------|----------------------------------------------------------| |--------------|--------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mode` | string | **Yes** | | The main color scheme mode | | `mode` | string | **Yes** | | Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.<br/>Continuous color interpolates a color using the percentage of a value relative to min and max.<br/>Accepted values are:<br/>`thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold<br/>`palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations<br/>`palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations<br/>`continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode<br/>`continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode<br/>`continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode<br/>`continuous-YlRd`: Continuous Yellow-Red palette mode<br/>`continuous-BlPu`: Continuous Blue-Purple palette mode<br/>`continuous-YlBl`: Continuous Yellow-Blue palette mode<br/>`continuous-blues`: Continuous Blue palette mode<br/>`continuous-reds`: Continuous Red palette mode<br/>`continuous-greens`: Continuous Green palette mode<br/>`continuous-purples`: Continuous Purple palette mode<br/>`shades`: Shades of a single color. Specify a single color, useful in an override rule.<br/>`fixed`: Fixed color mode. Specify a single color, useful in an override rule.<br/>Possible values are: `thresholds`, `palette-classic`, `palette-classic-by-name`, `continuous-GrYlRd`, `continuous-RdYlGr`, `continuous-BlYlRd`, `continuous-YlRd`, `continuous-BlPu`, `continuous-YlBl`, `continuous-blues`, `continuous-reds`, `continuous-greens`, `continuous-purples`, `fixed`, `shades`. |
| `fixedColor` | string | No | | Stores the fixed color value if mode is fixed | | `fixedColor` | string | No | | The fixed color value for fixed or shades color modes. |
| `seriesBy` | string | No | | TODO docs<br/>Possible values are: `min`, `max`, `last`. | | `seriesBy` | string | No | | Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.<br/>Possible values are: `min`, `max`, `last`. |
### ThresholdsConfig ### ThresholdsConfig
| Property | Type | Required | Default | Description | Thresholds configuration for the panel
|----------|---------------------------|----------|---------|------------------------------------------------------------------------------------------------------------------------------------------------|
| `mode` | string | **Yes** | | Thresholds can either be absolute (specific number) or percentage (relative to min or max).<br/>Possible values are: `absolute`, `percentage`. | | Property | Type | Required | Default | Description |
| `steps` | [Threshold](#threshold)[] | **Yes** | | Must be sorted by 'value', first value is always -Infinity | |----------|---------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mode` | string | **Yes** | | Thresholds can either be `absolute` (specific number) or `percentage` (relative to min or max, it will be values between 0 and 1).<br/>Possible values are: `absolute`, `percentage`. |
| `steps` | [Threshold](#threshold)[] | **Yes** | | Must be sorted by 'value', first value is always -Infinity |
### Threshold ### Threshold
User-defined value for a metric that triggers visual changes in a panel when this value is met or exceeded User-defined value for a metric that triggers visual changes in a panel when this value is met or exceeded
They are used to conditionally style and color visualizations based on query results , and can be applied to most visualizations. They are used to conditionally style and color visualizations based on query results , and can be applied to most visualizations.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------|---------|----------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |----------|--------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `color` | string | **Yes** | | Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded. | | `color` | string | **Yes** | | Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded. |
| `index` | integer | No | | Threshold index, an old property that is not needed an should only appear in older dashboards | | `value` | number | **Yes** | | Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded.<br/>Nulls currently appear here when serializing -Infinity to JSON. |
| `state` | string | No | | TODO docs<br/>TODO are the values here enumerable into a disjunction?<br/>Some seem to be listed in typescript comment |
| `value` | number | No | | Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded.<br/>FIXME the corresponding typescript field is required/non-optional, but nulls currently appear here when serializing -Infinity to JSON |
### ValueMapping ### ValueMapping
@ -273,52 +289,59 @@ Allow to transform the visual representation of specific data values in a visual
### RangeMap ### RangeMap
Maps numeric ranges to a color or different display text Maps numerical ranges to a display text and color.
For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-----------|--------------------|----------|---------|-------------| |-----------|--------------------|----------|---------|-----------------------------------------------------------------------------------|
| `options` | [object](#options) | **Yes** | | | | `options` | [object](#options) | **Yes** | | Range to match against and the result to apply when the value is within the range |
| `type` | string | **Yes** | | | | `type` | string | **Yes** | | |
### Options ### Options
| Property | Type | Required | Default | Description | Range to match against and the result to apply when the value is within the range
|----------|-------------------------------------------|----------|---------|--------------------------------------------------------------------------------|
| `from` | number | **Yes** | | to and from are `number &#124; null` in current ts, really not sure what to do | | Property | Type | Required | Default | Description |
| `result` | [ValueMappingResult](#valuemappingresult) | **Yes** | | Result used as replacement text and color for RegexMap and SpecialValueMap | |----------|-------------------------------------------|----------|---------|-----------------------------------------------------------------------|
| `to` | number | **Yes** | | | | `from` | number | **Yes** | | Min value of the range. It can be null which means -Infinity |
| `result` | [ValueMappingResult](#valuemappingresult) | **Yes** | | Result used as replacement with text and color when the value matches |
| `to` | number | **Yes** | | Max value of the range. It can be null which means +Infinity |
### ValueMappingResult ### ValueMappingResult
Result used as replacement text and color for RegexMap and SpecialValueMap Result used as replacement with text and color when the value matches
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------|---------|----------|---------|-------------| |----------|---------|----------|---------|-----------------------------------------------------------------------|
| `color` | string | No | | | | `color` | string | No | | Text to use when the value matches |
| `icon` | string | No | | | | `icon` | string | No | | Icon to display when the value matches. Only specific visualizations. |
| `index` | integer | No | | | | `index` | integer | No | | Position in the mapping array. Only used internally. |
| `text` | string | No | | | | `text` | string | No | | Text to display when the value matches |
### RegexMap ### RegexMap
Maps regular expressions to replacement text and a color Maps regular expressions to replacement text and a color.
For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-----------|--------------------|----------|---------|-------------| |-----------|--------------------|----------|---------|----------------------------------------------------------------------------------------------|
| `options` | [object](#options) | **Yes** | | | | `options` | [object](#options) | **Yes** | | Regular expression to match against and the result to apply when the value matches the regex |
| `type` | string | **Yes** | | | | `type` | string | **Yes** | | |
### Options ### Options
| Property | Type | Required | Default | Description | Regular expression to match against and the result to apply when the value matches the regex
|-----------|-------------------------------------------|----------|---------|----------------------------------------------------------------------------|
| `pattern` | string | **Yes** | | | | Property | Type | Required | Default | Description |
| `result` | [ValueMappingResult](#valuemappingresult) | **Yes** | | Result used as replacement text and color for RegexMap and SpecialValueMap | |-----------|-------------------------------------------|----------|---------|-----------------------------------------------------------------------|
| `pattern` | string | **Yes** | | Regular expression to match against |
| `result` | [ValueMappingResult](#valuemappingresult) | **Yes** | | Result used as replacement with text and color when the value matches |
### SpecialValueMap ### SpecialValueMap
Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color.
and color See SpecialValueMatch to see the list of special values.
For example, you can configure a special value mapping so that null values appear as N/A.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-----------|--------------------|----------|---------|-------------| |-----------|--------------------|----------|---------|-------------|
@ -327,20 +350,20 @@ and color
### Options ### Options
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-----------|-------------------------------------------|----------|---------|----------------------------------------------------------------------------| |----------|-------------------------------------------|----------|---------|--------------------------------------------------------------------------------------------------------------------------------------|
| `match` | string | **Yes** | | Possible values are: `true`, `false`. | | `match` | string | **Yes** | | Special value types supported by the `SpecialValueMap`<br/>Possible values are: `true`, `false`, `null`, `nan`, `null+nan`, `empty`. |
| `pattern` | string | **Yes** | | | | `result` | [ValueMappingResult](#valuemappingresult) | **Yes** | | Result used as replacement with text and color when the value matches |
| `result` | [ValueMappingResult](#valuemappingresult) | **Yes** | | Result used as replacement text and color for RegexMap and SpecialValueMap |
### ValueMap ### ValueMap
Maps text values to a color or different display text Maps text values to a color or different display text and color.
For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-----------|------------------------------------------------------|----------|---------|-------------| |-----------|------------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------|
| `options` | map[string][ValueMappingResult](#valuemappingresult) | **Yes** | | | | `options` | map[string][ValueMappingResult](#valuemappingresult) | **Yes** | | Map with <value_to_match>: ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } } |
| `type` | string | **Yes** | | | | `type` | string | **Yes** | | |
### Custom ### Custom
@ -352,10 +375,10 @@ in panel plugin schemas.
### Overrides ### Overrides
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|--------------|---------------------------------------------|----------|---------|-------------| |--------------|---------------------------------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `matcher` | [MatcherConfig](#matcherconfig) | **Yes** | | | | `matcher` | [MatcherConfig](#matcherconfig) | **Yes** | | Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.<br/>It comes with in id ( to resolve implementation from registry) and a configuration thats specific to a particular matcher type. |
| `properties` | [DynamicConfigValue](#dynamicconfigvalue)[] | **Yes** | | | | `properties` | [DynamicConfigValue](#dynamicconfigvalue)[] | **Yes** | | |
### DynamicConfigValue ### DynamicConfigValue
@ -366,7 +389,8 @@ in panel plugin schemas.
### GraphPanel ### GraphPanel
Support for legacy graph and heatmap panels. Support for legacy graph panel.
@deprecated this a deprecated panel type
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------|-------------------|----------|---------|----------------------------------------------------| |----------|-------------------|----------|---------|----------------------------------------------------|
@ -385,110 +409,126 @@ Support for legacy graph and heatmap panels.
### GridPos ### GridPos
| Property | Type | Required | Default | Description | Position and dimensions of a panel in the grid
|----------|---------|----------|---------|--------------------------------------------|
| `h` | uint32 | **Yes** | `9` | Panel | | Property | Type | Required | Default | Description |
| `w` | integer | **Yes** | `12` | Panel<br/>Constraint: `>0 & <=24`. | |----------|---------|----------|---------|-------------------------------------------------------------------------------------------------------------------|
| `x` | integer | **Yes** | `0` | Panel x<br/>Constraint: `>=0 & <24`. | | `h` | uint32 | **Yes** | `9` | Panel height. The height is the number of rows from the top edge of the panel. |
| `y` | uint32 | **Yes** | `0` | Panel y | | `w` | integer | **Yes** | `12` | Panel width. The width is the number of columns from the left edge of the panel.<br/>Constraint: `>0 & <=24`. |
| `static` | boolean | No | | Whether the panel is fixed within the grid | | `x` | integer | **Yes** | `0` | Panel x. The x coordinate is the number of columns from the left edge of the grid<br/>Constraint: `>=0 & <24`. |
| `y` | uint32 | **Yes** | `0` | Panel y. The y coordinate is the number of rows from the top edge of the grid |
| `static` | boolean | No | | Whether the panel is fixed within the grid. If true, the panel will not be affected by other panels' interactions |
### HeatmapPanel ### HeatmapPanel
Support for legacy heatmap panel.
@deprecated this a deprecated panel type
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------|--------|----------|---------|---------------------------------| |----------|--------|----------|---------|---------------------------------|
| `type` | string | **Yes** | | Possible values are: `heatmap`. | | `type` | string | **Yes** | | Possible values are: `heatmap`. |
### LibraryPanelRef ### LibraryPanelRef
| Property | Type | Required | Default | Description | A library panel is a reusable panel that you can use in any dashboard.
|----------|--------|----------|---------|-------------| When you make a change to a library panel, that change propagates to all instances of where the panel is used.
| `name` | string | **Yes** | | | Library panels streamline reuse of panels across multiple dashboards.
| `uid` | string | **Yes** | | |
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------|
| `name` | string | **Yes** | | Library panel name |
| `uid` | string | **Yes** | | Library panel uid |
### Panel ### Panel
Dashboard panels. Panels are canonically defined inline Dashboard panels are the basic visualization building blocks.
because they share a version timeline with the dashboard
schema; they do not evolve independently.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |-------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `fieldConfig` | [FieldConfigSource](#fieldconfigsource) | **Yes** | | | | `fieldConfig` | [FieldConfigSource](#fieldconfigsource) | **Yes** | | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.<br/>Each column within this structure is called a field. A field can represent a single time series or table column.<br/>Field options allow you to change how the data is displayed in your visualizations. |
| `options` | [object](#options) | **Yes** | | options is specified by the Options field in panel<br/>plugin schemas. | | `options` | [object](#options) | **Yes** | | It depends on the panel plugin. They are specified by the Options field in panel plugin schemas. |
| `repeatDirection` | string | **Yes** | `h` | Direction to repeat in if 'repeat' is set.<br/>"h" for horizontal, "v" for vertical.<br/>TODO this is probably optional<br/>Possible values are: `h`, `v`. | | `transformations` | [DataTransformerConfig](#datatransformerconfig)[] | **Yes** | | List of transformations that are applied to the panel data before rendering.<br/>When there are multiple transformations, Grafana applies them in the order they are listed.<br/>Each transformation creates a result set that then passes on to the next transformation in the processing pipeline. |
| `transformations` | [DataTransformerConfig](#datatransformerconfig)[] | **Yes** | | |
| `transparent` | boolean | **Yes** | `false` | Whether to display the panel without a background. | | `transparent` | boolean | **Yes** | `false` | Whether to display the panel without a background. |
| `type` | string | **Yes** | | The panel plugin type id. May not be empty.<br/>Constraint: `length >=1`. | | `type` | string | **Yes** | | The panel plugin type id. This is used to find the plugin to display the panel.<br/>Constraint: `length >=1`. |
| `datasource` | [object](#datasource) | No | | The datasource used in all targets. | | `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
| `description` | string | No | | Description. | | `description` | string | No | | Panel description. |
| `gridPos` | [GridPos](#gridpos) | No | | | | `gridPos` | [GridPos](#gridpos) | No | | Position and dimensions of a panel in the grid |
| `id` | uint32 | No | | TODO docs | | `id` | uint32 | No | | Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally. |
| `interval` | string | No | | The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.<br/>This value must be formatted as a number followed by a valid time<br/>identifier like: "40s", "3d", etc.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options | | `interval` | string | No | | The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.<br/>This value must be formatted as a number followed by a valid time<br/>identifier like: "40s", "3d", etc.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
| `libraryPanel` | [LibraryPanelRef](#librarypanelref) | No | | | | `libraryPanel` | [LibraryPanelRef](#librarypanelref) | No | | A library panel is a reusable panel that you can use in any dashboard.<br/>When you make a change to a library panel, that change propagates to all instances of where the panel is used.<br/>Library panels streamline reuse of panels across multiple dashboards. |
| `links` | [DashboardLink](#dashboardlink)[] | No | | Panel links.<br/>TODO fill this out - seems there are a couple variants? | | `links` | [DashboardLink](#dashboardlink)[] | No | | Panel links. |
| `maxDataPoints` | number | No | | The maximum number of data points that the panel queries are retrieving. | | `maxDataPoints` | number | No | | The maximum number of data points that the panel queries are retrieving. |
| `pluginVersion` | string | No | | FIXME this almost certainly has to be changed in favor of scuemata versions | | `pluginVersion` | string | No | | The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs. |
| `repeatDirection` | string | No | `h` | Direction to repeat in if 'repeat' is set.<br/>`h` for horizontal, `v` for vertical.<br/>Possible values are: `h`, `v`. |
| `repeatPanelId` | integer | No | | Id of the repeating panel. | | `repeatPanelId` | integer | No | | Id of the repeating panel. |
| `repeat` | string | No | | Name of template variable to repeat for. | | `repeat` | string | No | | Name of template variable to repeat for. |
| `tags` | string[] | No | | TODO docs | | `tags` | string[] | No | | Tags for the panel. |
| `targets` | [Target](#target)[] | No | | TODO docs | | `targets` | [Target](#target)[] | No | | Depends on the panel plugin. See the plugin documentation for details. |
| `thresholds` | | No | | TODO docs - seems to be an old field from old dashboard alerts? |
| `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboards time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options | | `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboards time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
| `timeRegions` | | No | | TODO docs |
| `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboards time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options | | `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboards time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
| `title` | string | No | | Panel title. | | `title` | string | No | | Panel title. |
### FieldConfigSource ### FieldConfigSource
| Property | Type | Required | Default | Description | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|-------------|-----------------------------|----------|---------|-------------| Each column within this structure is called a field. A field can represent a single time series or table column.
| `defaults` | [FieldConfig](#fieldconfig) | **Yes** | | | Field options allow you to change how the data is displayed in your visualizations.
| `overrides` | [overrides](#overrides)[] | **Yes** | | |
| Property | Type | Required | Default | Description |
|-------------|-----------------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `defaults` | [FieldConfig](#fieldconfig) | **Yes** | | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.<br/>Each column within this structure is called a field. A field can represent a single time series or table column.<br/>Field options allow you to change how the data is displayed in your visualizations. |
| `overrides` | [overrides](#overrides)[] | **Yes** | | Overrides are the options applied to specific fields overriding the defaults. |
### FieldConfig ### FieldConfig
| Property | Type | Required | Default | Description | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|---------------------|---------------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Each column within this structure is called a field. A field can represent a single time series or table column.
| `color` | [FieldColor](#fieldcolor) | No | | TODO docs | Field options allow you to change how the data is displayed in your visualizations.
| `custom` | [custom](#custom) | No | | custom is specified by the FieldConfig field<br/>in panel plugin schemas. |
| `decimals` | number | No | | Significant digits (for display) | | Property | Type | Required | Default | Description |
| `description` | string | No | | Human readable field metadata | |---------------------|---------------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `displayNameFromDS` | string | No | | This can be used by data sources that return and explicit naming structure for values and labels<br/>When this property is configured, this value is used rather than the default naming strategy. | | `color` | [FieldColor](#fieldcolor) | No | | Map a field to a color. |
| `displayName` | string | No | | The display value for this field. This supports template variables blank is auto | | `custom` | [custom](#custom) | No | | custom is specified by the FieldConfig field<br/>in panel plugin schemas. |
| `filterable` | boolean | No | | True if data source field supports ad-hoc filters | | `decimals` | number | No | | Specify the number of decimals Grafana includes in the rendered value.<br/>If you leave this field blank, Grafana automatically truncates the number of decimals based on the value.<br/>For example 1.1234 will display as 1.12 and 100.456 will display as 100.<br/>To display all decimals, set the unit to `String`. |
| `links` | | No | | The behavior when clicking on a result | | `description` | string | No | | Human readable field metadata |
| `mappings` | [ValueMapping](#valuemapping)[] | No | | Convert input values into a display string | | `displayNameFromDS` | string | No | | This can be used by data sources that return and explicit naming structure for values and labels<br/>When this property is configured, this value is used rather than the default naming strategy. |
| `max` | number | No | | | | `displayName` | string | No | | The display value for this field. This supports template variables blank is auto |
| `min` | number | No | | | | `filterable` | boolean | No | | True if data source field supports ad-hoc filters |
| `noValue` | string | No | | Alternative to empty string | | `links` | | No | | The behavior when clicking on a result |
| `path` | string | No | | An explicit path to the field in the datasource. When the frame meta includes a path,<br/>This will default to `${frame.meta.path}/${field.name}<br/><br/>When defined, this value can be used as an identifier within the datasource scope, and<br/>may be used to update the results | | `mappings` | [ValueMapping](#valuemapping)[] | No | | Convert input values into a display string |
| `thresholds` | [ThresholdsConfig](#thresholdsconfig) | No | | | | `max` | number | No | | The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. |
| `unit` | string | No | | Numeric Options | | `min` | number | No | | The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. |
| `writeable` | boolean | No | | True if data source can write a value to the path. Auth/authz are supported separately | | `noValue` | string | No | | Alternative to empty string |
| `path` | string | No | | An explicit path to the field in the datasource. When the frame meta includes a path,<br/>This will default to `${frame.meta.path}/${field.name}<br/><br/>When defined, this value can be used as an identifier within the datasource scope, and<br/>may be used to update the results |
| `thresholds` | [ThresholdsConfig](#thresholdsconfig) | No | | Thresholds configuration for the panel |
| `unit` | string | No | | Unit a field should use. The unit you select is applied to all fields except time.<br/>You can use the units ID availables in Grafana or a custom unit.<br/>Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts<br/>As custom unit, you can use the following formats:<br/>`suffix:<suffix>` for custom unit that should go after value.<br/>`prefix:<prefix>` for custom unit that should go before value.<br/>`time:<format>` For custom date time formats type for example `time:YYYY-MM-DD`.<br/>`si:<base scale><unit characters>` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character.<br/>`count:<unit>` for a custom count unit.<br/>`currency:<unit>` for custom a currency unit. |
| `writeable` | boolean | No | | True if data source can write a value to the path. Auth/authz are supported separately |
### RangeMap ### RangeMap
Maps numeric ranges to a color or different display text Maps numerical ranges to a display text and color.
For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-----------|---------------------|----------|---------|-------------| |-----------|---------------------|----------|---------|-----------------------------------------------------------------------------------|
| `options` | [options](#options) | **Yes** | | | | `options` | [options](#options) | **Yes** | | Range to match against and the result to apply when the value is within the range |
| `type` | string | **Yes** | | | | `type` | string | **Yes** | | |
### RegexMap ### RegexMap
Maps regular expressions to replacement text and a color Maps regular expressions to replacement text and a color.
For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-----------|---------------------|----------|---------|-------------| |-----------|---------------------|----------|---------|----------------------------------------------------------------------------------------------|
| `options` | [options](#options) | **Yes** | | | | `options` | [options](#options) | **Yes** | | Regular expression to match against and the result to apply when the value matches the regex |
| `type` | string | **Yes** | | | | `type` | string | **Yes** | | |
### SpecialValueMap ### SpecialValueMap
Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color.
and color See SpecialValueMatch to see the list of special values.
For example, you can configure a special value mapping so that null values appear as N/A.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-----------|---------------------|----------|---------|-------------| |-----------|---------------------|----------|---------|-------------|
@ -508,19 +548,9 @@ type directly to achieve the same effect.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------|------|----------|---------|-------------| |----------|------|----------|---------|-------------|
### Datasource
The datasource used in all targets.
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|-------------|
| `type` | string | No | | |
| `uid` | string | No | | |
### Options ### Options
options is specified by the Options field in panel It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
plugin schemas.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------|------|----------|---------|-------------| |----------|------|----------|---------|-------------|
@ -529,25 +559,16 @@ plugin schemas.
Row panel Row panel
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|--------------|-----------------------|----------|---------|------------------------------------------| |--------------|---------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|
| `collapsed` | boolean | **Yes** | `false` | | | `collapsed` | boolean | **Yes** | `false` | Whether this row should be collapsed or not. |
| `id` | uint32 | **Yes** | | | | `id` | uint32 | **Yes** | | Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally. |
| `panels` | [panels](#panels)[] | **Yes** | | | | `panels` | [panels](#panels)[] | **Yes** | | List of panels in the row |
| `type` | string | **Yes** | | Possible values are: `row`. | | `type` | string | **Yes** | | The panel type<br/>Possible values are: `row`. |
| `datasource` | [object](#datasource) | No | | Name of default datasource. | | `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
| `gridPos` | [GridPos](#gridpos) | No | | | | `gridPos` | [GridPos](#gridpos) | No | | Position and dimensions of a panel in the grid |
| `repeat` | string | No | | Name of template variable to repeat for. | | `repeat` | string | No | | Name of template variable to repeat for. |
| `title` | string | No | | | | `title` | string | No | | Row title |
### Datasource
Name of default datasource.
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|-------------|
| `type` | string | No | | |
| `uid` | string | No | | |
### Panels ### Panels
@ -557,7 +578,8 @@ Name of default datasource.
### GraphPanel ### GraphPanel
Support for legacy graph and heatmap panels. Support for legacy graph panel.
@deprecated this a deprecated panel type
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------|-------------------|----------|---------|----------------------------------------------------| |----------|-------------------|----------|---------|----------------------------------------------------|
@ -566,73 +588,71 @@ Support for legacy graph and heatmap panels.
### Panel ### Panel
Dashboard panels. Panels are canonically defined inline Dashboard panels are the basic visualization building blocks.
because they share a version timeline with the dashboard
schema; they do not evolve independently.
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|-------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |-------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `fieldConfig` | [FieldConfigSource](#fieldconfigsource) | **Yes** | | | | `fieldConfig` | [FieldConfigSource](#fieldconfigsource) | **Yes** | | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.<br/>Each column within this structure is called a field. A field can represent a single time series or table column.<br/>Field options allow you to change how the data is displayed in your visualizations. |
| `options` | [options](#options) | **Yes** | | options is specified by the Options field in panel<br/>plugin schemas. | | `options` | [options](#options) | **Yes** | | It depends on the panel plugin. They are specified by the Options field in panel plugin schemas. |
| `repeatDirection` | string | **Yes** | `h` | Direction to repeat in if 'repeat' is set.<br/>"h" for horizontal, "v" for vertical.<br/>TODO this is probably optional<br/>Possible values are: `h`, `v`. | | `transformations` | [DataTransformerConfig](#datatransformerconfig)[] | **Yes** | | List of transformations that are applied to the panel data before rendering.<br/>When there are multiple transformations, Grafana applies them in the order they are listed.<br/>Each transformation creates a result set that then passes on to the next transformation in the processing pipeline. |
| `transformations` | [DataTransformerConfig](#datatransformerconfig)[] | **Yes** | | |
| `transparent` | boolean | **Yes** | `false` | Whether to display the panel without a background. | | `transparent` | boolean | **Yes** | `false` | Whether to display the panel without a background. |
| `type` | string | **Yes** | | The panel plugin type id. May not be empty.<br/>Constraint: `length >=1`. | | `type` | string | **Yes** | | The panel plugin type id. This is used to find the plugin to display the panel.<br/>Constraint: `length >=1`. |
| `datasource` | [datasource](#datasource) | No | | The datasource used in all targets. | | `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
| `description` | string | No | | Description. | | `description` | string | No | | Panel description. |
| `gridPos` | [GridPos](#gridpos) | No | | | | `gridPos` | [GridPos](#gridpos) | No | | Position and dimensions of a panel in the grid |
| `id` | uint32 | No | | TODO docs | | `id` | uint32 | No | | Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally. |
| `interval` | string | No | | The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.<br/>This value must be formatted as a number followed by a valid time<br/>identifier like: "40s", "3d", etc.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options | | `interval` | string | No | | The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.<br/>This value must be formatted as a number followed by a valid time<br/>identifier like: "40s", "3d", etc.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
| `libraryPanel` | [LibraryPanelRef](#librarypanelref) | No | | | | `libraryPanel` | [LibraryPanelRef](#librarypanelref) | No | | A library panel is a reusable panel that you can use in any dashboard.<br/>When you make a change to a library panel, that change propagates to all instances of where the panel is used.<br/>Library panels streamline reuse of panels across multiple dashboards. |
| `links` | [DashboardLink](#dashboardlink)[] | No | | Panel links.<br/>TODO fill this out - seems there are a couple variants? | | `links` | [DashboardLink](#dashboardlink)[] | No | | Panel links. |
| `maxDataPoints` | number | No | | The maximum number of data points that the panel queries are retrieving. | | `maxDataPoints` | number | No | | The maximum number of data points that the panel queries are retrieving. |
| `pluginVersion` | string | No | | FIXME this almost certainly has to be changed in favor of scuemata versions | | `pluginVersion` | string | No | | The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs. |
| `repeatDirection` | string | No | `h` | Direction to repeat in if 'repeat' is set.<br/>`h` for horizontal, `v` for vertical.<br/>Possible values are: `h`, `v`. |
| `repeatPanelId` | integer | No | | Id of the repeating panel. | | `repeatPanelId` | integer | No | | Id of the repeating panel. |
| `repeat` | string | No | | Name of template variable to repeat for. | | `repeat` | string | No | | Name of template variable to repeat for. |
| `tags` | string[] | No | | TODO docs | | `tags` | string[] | No | | Tags for the panel. |
| `targets` | [Target](#target)[] | No | | TODO docs | | `targets` | [Target](#target)[] | No | | Depends on the panel plugin. See the plugin documentation for details. |
| `thresholds` | | No | | TODO docs - seems to be an old field from old dashboard alerts? |
| `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboards time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options | | `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboards time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
| `timeRegions` | | No | | TODO docs |
| `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboards time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options | | `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboards time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
| `title` | string | No | | Panel title. | | `title` | string | No | | Panel title. |
### Templating ### Templating
Contains the list of configured template variables with their saved values along with some other metadata Configured template variables
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------|-----------------------------------|----------|---------|-------------| |----------|-----------------------------------|----------|---------|----------------------------------------------------------------------------------------------|
| `list` | [VariableModel](#variablemodel)[] | No | | | | `list` | [VariableModel](#variablemodel)[] | No | | List of configured template variables with their saved values along with some other metadata |
### VariableModel ### VariableModel
FROM: packages/grafana-data/src/types/templateVars.ts A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
TODO docs
TODO what about what's in public/app/features/types.ts?
TODO there appear to be a lot of different kinds of [template] vars here? if so need a disjunction
| Property | Type | Required | Default | Description | | Property | Type | Required | Default | Description |
|----------------|---------------------------------|----------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |---------------|-------------------------------------|----------|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `global` | boolean | **Yes** | `false` | | | `hide` | integer | **Yes** | | Determine if the variable shows on dashboard<br/>Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).<br/>Possible values are: `0`, `1`, `2`. |
| `hide` | integer | **Yes** | | Possible values are: `0`, `1`, `2`. | | `id` | string | **Yes** | `00000000-0000-0000-0000-000000000000` | Unique numeric identifier for the variable. |
| `id` | string | **Yes** | `00000000-0000-0000-0000-000000000000` | | | `name` | string | **Yes** | | Name of variable |
| `index` | int32 | **Yes** | `-1` | | | `skipUrlSync` | boolean | **Yes** | `false` | Whether the variable value should be managed by URL query params or not |
| `name` | string | **Yes** | | | | `type` | string | **Yes** | | Dashboard variable type<br/>`query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.<br/>`adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).<br/>`constant`: Define a hidden constant.<br/>`datasource`: Quickly change the data source for an entire dashboard.<br/>`interval`: Interval variables represent time spans.<br/>`textbox`: Display a free text input field with an optional default value.<br/>`custom`: Define the variable options manually using a comma-separated list.<br/>`system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables<br/>Possible values are: `query`, `adhoc`, `constant`, `datasource`, `interval`, `textbox`, `custom`, `system`. |
| `skipUrlSync` | boolean | **Yes** | `false` | | | `allFormat` | string | No | | Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc. |
| `state` | string | **Yes** | | Possible values are: `NotStarted`, `Loading`, `Streaming`, `Done`, `Error`. | | `current` | [VariableOption](#variableoption) | No | | Option to be selected in a variable. |
| `type` | string | **Yes** | | FROM: packages/grafana-data/src/types/templateVars.ts<br/>TODO docs<br/>TODO this implies some wider pattern/discriminated union, probably?<br/>Possible values are: `query`, `adhoc`, `constant`, `datasource`, `interval`, `textbox`, `custom`, `system`. | | `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
| `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance | | `description` | string | No | | Description of variable. It can be defined but `null`. |
| `description` | string | No | | | | `label` | string | No | | Optional display name |
| `error` | [object](#error) | No | | | | `multi` | boolean | No | `false` | Whether multiple values can be selected or not from variable value list |
| `label` | string | No | | | | `options` | [VariableOption](#variableoption)[] | No | | Options that can be selected for a variable. |
| `query` | | No | | TODO: Move this into a separated QueryVariableModel type | | `query` | | No | | Query used to fetch values for a variable |
| `rootStateKey` | string | No | | | | `refresh` | integer | No | | Options to config when to refresh a variable<br/>`0`: Never refresh the variable<br/>`1`: Queries the data source every time the dashboard loads.<br/>`2`: Queries the data source when the dashboard time range changes.<br/>Possible values are: `0`, `1`, `2`. |
### Error ### VariableOption
| Property | Type | Required | Default | Description | Option to be selected in a variable.
|----------|------|----------|---------|-------------|
| Property | Type | Required | Default | Description |
|------------|---------|----------|---------|---------------------------------------|
| `text` | | **Yes** | | Text to be displayed for the option |
| `value` | | **Yes** | | Value of the option |
| `selected` | boolean | No | | Whether the option is selected or not |
### Time ### Time

View File

@ -16,37 +16,48 @@ lineage: schemas: [{
schema: { schema: {
spec: { spec: {
// Unique numeric identifier for the dashboard. // Unique numeric identifier for the dashboard.
// TODO must isolate or remove identifiers local to a Grafana instance...? // `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
id?: int64 id?: int64
// Unique dashboard identifier that can be generated by anyone. string (8-40) // Unique dashboard identifier that can be generated by anyone. string (8-40)
uid?: string uid?: string
// Title of dashboard. // Title of dashboard.
title?: string title?: string
// Description of dashboard. // Description of dashboard.
description?: string description?: string
// This property should only be used in dashboards defined by plugins. It is a quick check // This property should only be used in dashboards defined by plugins. It is a quick check
// to see if the version has changed since the last time. Unclear why using the version property // to see if the version has changed since the last time.
// is insufficient. revision?: int64
revision?: int64 @grafanamaturity(NeedsExpertReview)
// ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal // ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal
gnetId?: string @grafanamaturity(NeedsExpertReview) gnetId?: string
// Tags associated with dashboard. // Tags associated with dashboard.
tags?: [...string] @grafanamaturity(NeedsExpertReview) tags?: [...string]
// Theme of dashboard. // Theme of dashboard.
style: "light" | *"dark" @grafanamaturity(NeedsExpertReview) // Default value: dark.
style: "light" | *"dark"
// Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc". // Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc".
timezone?: string | *"browser" timezone?: string | *"browser"
// Whether a dashboard is editable or not. // Whether a dashboard is editable or not.
editable: bool | *true editable: bool | *true
// Configuration of dashboard cursor sync behavior. // Configuration of dashboard cursor sync behavior.
// Accepted values are 0 (sync turned off), 1 (shared crosshair), 2 (shared crosshair and tooltip). // Accepted values are 0 (sync turned off), 1 (shared crosshair), 2 (shared crosshair and tooltip).
graphTooltip: #DashboardCursorSync graphTooltip: #DashboardCursorSync
// Time range for dashboard. // Time range for dashboard.
// Accepted values are relative time strings like {from: 'now-6h', to: 'now'} or absolute time strings like {from: '2020-07-10T08:00:00.000Z', to: '2020-07-10T14:00:00.000Z'}. // Accepted values are relative time strings like {from: 'now-6h', to: 'now'} or absolute time strings like {from: '2020-07-10T08:00:00.000Z', to: '2020-07-10T14:00:00.000Z'}.
time?: { time?: {
from: string | *"now-6h" from: string | *"now-6h"
to: string | *"now" to: string | *"now"
} @grafanamaturity(NeedsExpertReview) }
// Configuration of the time picker shown at the top of a dashboard. // Configuration of the time picker shown at the top of a dashboard.
timepicker?: { timepicker?: {
@ -60,36 +71,48 @@ lineage: schemas: [{
enable: bool | *true enable: bool | *true
// Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard. // Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard.
time_options: [...string] | *["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"] time_options: [...string] | *["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"]
} @grafanamaturity(NeedsExpertReview) }
// The month that the fiscal year starts on. 0 = January, 11 = December // The month that the fiscal year starts on. 0 = January, 11 = December
fiscalYearStartMonth?: uint8 & <12 | *0 fiscalYearStartMonth?: uint8 & <12 | *0
// When set to true, the dashboard will redraw panels at an interval matching the pixel width. // When set to true, the dashboard will redraw panels at an interval matching the pixel width.
// This will keep data "moving left" regardless of the query refresh rate. This setting helps // This will keep data "moving left" regardless of the query refresh rate. This setting helps
// avoid dashboards presenting stale live data // avoid dashboards presenting stale live data
liveNow?: bool @grafanamaturity(NeedsExpertReview) liveNow?: bool
// Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday". // Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday".
weekStart?: string weekStart?: string
// Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". // Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
refresh?: string | false refresh?: string | false
// Version of the JSON schema, incremented each time a Grafana update brings // Version of the JSON schema, incremented each time a Grafana update brings
// changes to said schema. // changes to said schema.
// TODO this is the existing schema numbering system. It will be replaced by Thema's themaVersion
schemaVersion: uint16 | *36 schemaVersion: uint16 | *36
// Version of the dashboard, incremented each time the dashboard is updated. // Version of the dashboard, incremented each time the dashboard is updated.
version?: uint32 @grafanamaturity(NeedsExpertReview) version?: uint32
panels?: [...(#Panel | #RowPanel | #GraphPanel | #HeatmapPanel)] @grafanamaturity(NeedsExpertReview)
// Contains the list of configured template variables with their saved values along with some other metadata // List of dashboard panels
panels?: [...(#Panel | #RowPanel | #GraphPanel | #HeatmapPanel)]
// Configured template variables
templating?: { templating?: {
list?: [...#VariableModel] @grafanamaturity(NeedsExpertReview) // List of configured template variables with their saved values along with some other metadata
list?: [...#VariableModel]
} }
// TODO docs // Contains the list of annotations that are associated with the dashboard.
// Annotations are used to overlay event markers and overlay event tags on graphs.
// Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
// See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
annotations?: #AnnotationContainer annotations?: #AnnotationContainer
// Links with references to other dashboards or external websites. // Links with references to other dashboards or external websites.
links?: [...#DashboardLink] @grafanamaturity(NeedsExpertReview) links?: [...#DashboardLink]
// Snapshot options. They are present only if the dashboard is a snapshot.
snapshot?: #Snapshot @grafanamaturity(NeedsExpertReview) snapshot?: #Snapshot @grafanamaturity(NeedsExpertReview)
} @cuetsy(kind="interface") @grafana(TSVeneer="type") } @cuetsy(kind="interface") @grafana(TSVeneer="type")
@ -122,19 +145,18 @@ lineage: schemas: [{
ids: [...uint8] ids: [...uint8]
} @cuetsy(kind="interface") } @cuetsy(kind="interface")
// TODO -- should not be a public interface on its own, but required for Veneer // Contains the list of annotations that are associated with the dashboard.
// Annotations are used to overlay event markers and overlay event tags on graphs.
// Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
// See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
#AnnotationContainer: { #AnnotationContainer: {
// annoying... but required so that the list is defined using the nested Veneer // List of annotations
@grafana(TSVeneer="type") list?: [...#AnnotationQuery]
} @cuetsy(kind="interface") @grafana(TSVeneer="type")
list?: [...#AnnotationQuery] @grafanamaturity(NeedsExpertReview)
} @cuetsy(kind="interface")
// TODO docs // TODO docs
// FROM: AnnotationQuery in grafana-data/src/types/annotations.ts // FROM: AnnotationQuery in grafana-data/src/types/annotations.ts
#AnnotationQuery: { #AnnotationQuery: {
@grafana(TSVeneer="type")
// Name of annotation. // Name of annotation.
name: string name: string
@ -163,199 +185,279 @@ lineage: schemas: [{
// unless datasources have migrated to the target+mapping, // unless datasources have migrated to the target+mapping,
// they just spread their query into the base object :( // they just spread their query into the base object :(
... ...
} @cuetsy(kind="interface") } @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
#LoadingState: "NotStarted" | "Loading" | "Streaming" | "Done" | "Error" @cuetsy(kind="enum") @grafanamaturity(NeedsExpertReview) // A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
// FROM: packages/grafana-data/src/types/templateVars.ts
// TODO docs
// TODO what about what's in public/app/features/types.ts?
// TODO there appear to be a lot of different kinds of [template] vars here? if so need a disjunction
#VariableModel: { #VariableModel: {
id: string | *"00000000-0000-0000-0000-000000000000" // Unique numeric identifier for the variable.
type: #VariableType id: string | *"00000000-0000-0000-0000-000000000000"
name: string // Type of variable
label?: string type: #VariableType
rootStateKey?: string // Name of variable
global: bool | *false name: string
hide: #VariableHide // Optional display name
skipUrlSync: bool | *false label?: string
index: int32 | *-1 // Visibility configuration for the variable
state: #LoadingState hide: #VariableHide
error?: {...} // Whether the variable value should be managed by URL query params or not
skipUrlSync: bool | *false
// Description of variable. It can be defined but `null`.
description?: string description?: string
// TODO: Move this into a separated QueryVariableModel type // Query used to fetch values for a variable
query?: string | {...} query?: string | {...}
// Data source used to fetch values for a variable. It can be defined but `null`.
datasource?: #DataSourceRef datasource?: #DataSourceRef
// Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc.
allFormat?: string
// Shows current selected variable text/value on the dashboard
current?: #VariableOption
// Whether multiple values can be selected or not from variable value list
multi?: bool | *false
// Options that can be selected for a variable.
options?: [...#VariableOption]
refresh?: #VariableRefresh
... ...
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
#VariableHide: 0 | 1 | 2 @cuetsy(kind="enum",memberNames="dontHide|hideLabel|hideVariable") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
#LoadingState: "NotStarted" | "Loading" | "Streaming" | "Done" | "Error" @cuetsy(kind="enum") @grafanamaturity(NeedsExpertReview) // Option to be selected in a variable.
#VariableOption: {
// Whether the option is selected or not
selected?: bool
// Text to be displayed for the option
text: string | [...string]
// Value of the option
value: string | [...string]
} @cuetsy(kind="interface")
// Options to config when to refresh a variable
// `0`: Never refresh the variable
// `1`: Queries the data source every time the dashboard loads.
// `2`: Queries the data source when the dashboard time range changes.
#VariableRefresh: 0 | 1 | 2 @cuetsy(kind="enum",memberNames="never|onDashboardLoad|onTimeRangeChanged")
// Determine if the variable shows on dashboard
// Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
#VariableHide: 0 | 1 | 2 @cuetsy(kind="enum",memberNames="dontHide|hideLabel|hideVariable") @grafana(TSVeneer="type")
// Sort variable options
// Accepted values are:
// `0`: No sorting
// `1`: Alphabetical ASC
// `2`: Alphabetical DESC
// `3`: Numerical ASC
// `4`: Numerical DESC
// `5`: Alphabetical Case Insensitive ASC
// `6`: Alphabetical Case Insensitive DESC
#VariableSort: 0 | 1 | 2 | 3 | 4 | 5 | 6 @cuetsy(kind="enum",memberNames="disabled|alphabeticalAsc|alphabeticalDesc|numericalAsc|numericalDesc|alphabeticalCaseInsensitiveAsc|alphabeticalCaseInsensitiveDesc")
// Loading status
// Accepted values are `NotStarted` (the request is not started), `Loading` (waiting for response), `Streaming` (pulling continuous data), `Done` (response received successfully) or `Error` (failed request).
#LoadingState: "NotStarted" | "Loading" | "Streaming" | "Done" | "Error" @cuetsy(kind="enum")
// Ref to a DataSource instance // Ref to a DataSource instance
#DataSourceRef: { #DataSourceRef: {
// The plugin type-id // The plugin type-id
type?: string @grafanamaturity(NeedsExpertReview) type?: string
// Specific datasource instance // Specific datasource instance
uid?: string @grafanamaturity(NeedsExpertReview) uid?: string
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface") @grafana(TSVeneer="type")
// Links with references to other dashboards or external resources // Links with references to other dashboards or external resources
#DashboardLink: { #DashboardLink: {
// Title to display with the link // Title to display with the link
title: string @grafanamaturity(NeedsExpertReview) title: string
// Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) // Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
type: #DashboardLinkType @grafanamaturity(NeedsExpertReview) type: #DashboardLinkType
// Icon name to be displayed with the link // Icon name to be displayed with the link
icon: string @grafanamaturity(NeedsExpertReview) icon: string
// Tooltip to display when the user hovers their mouse over it // Tooltip to display when the user hovers their mouse over it
tooltip: string @grafanamaturity(NeedsExpertReview) tooltip: string
// Link URL. Only required/valid if the type is link // Link URL. Only required/valid if the type is link
url: string @grafanamaturity(NeedsExpertReview) url: string
// List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards // List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards
tags: [...string] @grafanamaturity(NeedsExpertReview) tags: [...string]
// If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards // If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards
asDropdown: bool | *false @grafanamaturity(NeedsExpertReview) asDropdown: bool | *false
// If true, the link will be opened in a new tab // If true, the link will be opened in a new tab
targetBlank: bool | *false @grafanamaturity(NeedsExpertReview) targetBlank: bool | *false
// If true, includes current template variables values in the link as query params // If true, includes current template variables values in the link as query params
includeVars: bool | *false @grafanamaturity(NeedsExpertReview) includeVars: bool | *false
// If true, includes current time range in the link as query params // If true, includes current time range in the link as query params
keepTime: bool | *false @grafanamaturity(NeedsExpertReview) keepTime: bool | *false
} @cuetsy(kind="interface") } @cuetsy(kind="interface")
// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) // Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
#DashboardLinkType: "link" | "dashboards" @cuetsy(kind="type") @grafanamaturity(NeedsExpertReview) #DashboardLinkType: "link" | "dashboards" @cuetsy(kind="type")
// FROM: packages/grafana-data/src/types/templateVars.ts // Dashboard variable type
// TODO docs // `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
// TODO this implies some wider pattern/discriminated union, probably? // `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
// `constant`: Define a hidden constant.
// `datasource`: Quickly change the data source for an entire dashboard.
// `interval`: Interval variables represent time spans.
// `textbox`: Display a free text input field with an optional default value.
// `custom`: Define the variable options manually using a comma-separated list.
// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
#VariableType: "query" | "adhoc" | "constant" | "datasource" | "interval" | "textbox" | "custom" | "system" @cuetsy(kind="type") @grafanamaturity(NeedsExpertReview) #VariableType: "query" | "adhoc" | "constant" | "datasource" | "interval" | "textbox" | "custom" | "system" @cuetsy(kind="type") @grafanamaturity(NeedsExpertReview)
// TODO docs // Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.
#FieldColorModeId: "thresholds" | "palette-classic" | "palette-saturated" | "continuous-GrYlRd" | "fixed" @cuetsy(kind="enum",memberNames="Thresholds|PaletteClassic|PaletteSaturated|ContinuousGrYlRd|Fixed") @grafanamaturity(NeedsExpertReview) // Continuous color interpolates a color using the percentage of a value relative to min and max.
// Accepted values are:
// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold
// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations
// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations
// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode
// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode
// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode
// `continuous-YlRd`: Continuous Yellow-Red palette mode
// `continuous-BlPu`: Continuous Blue-Purple palette mode
// `continuous-YlBl`: Continuous Yellow-Blue palette mode
// `continuous-blues`: Continuous Blue palette mode
// `continuous-reds`: Continuous Red palette mode
// `continuous-greens`: Continuous Green palette mode
// `continuous-purples`: Continuous Purple palette mode
// `shades`: Shades of a single color. Specify a single color, useful in an override rule.
// `fixed`: Fixed color mode. Specify a single color, useful in an override rule.
#FieldColorModeId: "thresholds" | "palette-classic" | "palette-classic-by-name" | "continuous-GrYlRd" | "continuous-RdYlGr" | "continuous-BlYlRd" | "continuous-YlRd" | "continuous-BlPu" | "continuous-YlBl" | "continuous-blues" | "continuous-reds" | "continuous-greens" | "continuous-purples" | "fixed" | "shades" @cuetsy(kind="enum",memberNames="Thresholds|PaletteClassic|PaletteClassicByName|ContinuousGrYlRd|ContinuousRdYlGr|ContinuousBlYlRd|ContinuousYlRd|ContinuousBlPu|ContinuousYlBl|ContinuousBlues|ContinuousReds|ContinuousGreens|ContinuousPurples|Fixed|Shades") @grafanamaturity(NeedsExpertReview)
// TODO docs // Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.
#FieldColorSeriesByMode: "min" | "max" | "last" @cuetsy(kind="type") @grafanamaturity(NeedsExpertReview) #FieldColorSeriesByMode: "min" | "max" | "last" @cuetsy(kind="type")
// TODO docs // Map a field to a color.
#FieldColor: { #FieldColor: {
// The main color scheme mode // The main color scheme mode.
mode: #FieldColorModeId | string mode: #FieldColorModeId
// Stores the fixed color value if mode is fixed // The fixed color value for fixed or shades color modes.
fixedColor?: string fixedColor?: string
// Some visualizations need to know how to assign a series color from by value color schemes // Some visualizations need to know how to assign a series color from by value color schemes.
seriesBy?: #FieldColorSeriesByMode seriesBy?: #FieldColorSeriesByMode
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface")
// Position and dimensions of a panel in the grid
#GridPos: { #GridPos: {
// Panel // Panel height. The height is the number of rows from the top edge of the panel.
h: uint32 & >0 | *9 @grafanamaturity(NeedsExpertReview) h: uint32 & >0 | *9
// Panel // Panel width. The width is the number of columns from the left edge of the panel.
w: uint32 & >0 & <=24 | *12 @grafanamaturity(NeedsExpertReview) w: uint32 & >0 & <=24 | *12
// Panel x // Panel x. The x coordinate is the number of columns from the left edge of the grid
x: uint32 & >=0 & <24 | *0 @grafanamaturity(NeedsExpertReview) x: uint32 & >=0 & <24 | *0
// Panel y // Panel y. The y coordinate is the number of rows from the top edge of the grid
y: uint32 & >=0 | *0 @grafanamaturity(NeedsExpertReview) y: uint32 & >=0 | *0
// Whether the panel is fixed within the grid // Whether the panel is fixed within the grid. If true, the panel will not be affected by other panels' interactions
static?: bool @grafanamaturity(NeedsExpertReview) static?: bool
} @cuetsy(kind="interface") } @cuetsy(kind="interface")
// User-defined value for a metric that triggers visual changes in a panel when this value is met or exceeded // User-defined value for a metric that triggers visual changes in a panel when this value is met or exceeded
// They are used to conditionally style and color visualizations based on query results , and can be applied to most visualizations. // They are used to conditionally style and color visualizations based on query results , and can be applied to most visualizations.
#Threshold: { #Threshold: {
// Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded. // Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded.
// FIXME the corresponding typescript field is required/non-optional, but nulls currently appear here when serializing -Infinity to JSON // Nulls currently appear here when serializing -Infinity to JSON.
value?: number @grafanamaturity(NeedsExpertReview) value: number @grafanamaturity(NeedsExpertReview)
// Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded. // Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded.
color: string @grafanamaturity(NeedsExpertReview) color: string @grafanamaturity(NeedsExpertReview)
// Threshold index, an old property that is not needed an should only appear in older dashboards } @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
index?: int32 @grafanamaturity(NeedsExpertReview)
// TODO docs
// TODO are the values here enumerable into a disjunction?
// Some seem to be listed in typescript comment
state?: string @grafanamaturity(NeedsExpertReview)
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview)
// Thresholds can either be absolute (specific number) or percentage (relative to min or max). // Thresholds can either be `absolute` (specific number) or `percentage` (relative to min or max, it will be values between 0 and 1).
#ThresholdsMode: "absolute" | "percentage" @cuetsy(kind="enum") @grafanamaturity(NeedsExpertReview) #ThresholdsMode: "absolute" | "percentage" @cuetsy(kind="enum",memberNames="Absolute|Percentage")
// Thresholds configuration for the panel
#ThresholdsConfig: { #ThresholdsConfig: {
mode: #ThresholdsMode @grafanamaturity(NeedsExpertReview) // Thresholds mode.
mode: #ThresholdsMode
// Must be sorted by 'value', first value is always -Infinity // Must be sorted by 'value', first value is always -Infinity
steps: [...#Threshold] @grafanamaturity(NeedsExpertReview) steps: [...#Threshold] @grafanamaturity(NeedsExpertReview)
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
// Allow to transform the visual representation of specific data values in a visualization, irrespective of their original units // Allow to transform the visual representation of specific data values in a visualization, irrespective of their original units
#ValueMapping: #ValueMap | #RangeMap | #RegexMap | #SpecialValueMap @cuetsy(kind="type") @grafanamaturity(NeedsExpertReview) #ValueMapping: #ValueMap | #RangeMap | #RegexMap | #SpecialValueMap @cuetsy(kind="type") @grafanamaturity(NeedsExpertReview) @grafana(TSVeneer="type")
// Supported value mapping types // Supported value mapping types
// `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
// `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
// `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
// `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A.
#MappingType: "value" | "range" | "regex" | "special" @cuetsy(kind="enum",memberNames="ValueToText|RangeToText|RegexToText|SpecialValue") @grafanamaturity(NeedsExpertReview) #MappingType: "value" | "range" | "regex" | "special" @cuetsy(kind="enum",memberNames="ValueToText|RangeToText|RegexToText|SpecialValue") @grafanamaturity(NeedsExpertReview)
// Maps text values to a color or different display text // Maps text values to a color or different display text and color.
// For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
#ValueMap: { #ValueMap: {
type: #MappingType & "value" type: #MappingType & "value"
// Map with <value_to_match>: ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } }
options: [string]: #ValueMappingResult options: [string]: #ValueMappingResult
} @cuetsy(kind="interface") } @cuetsy(kind="interface")
// Maps numeric ranges to a color or different display text // Maps numerical ranges to a display text and color.
// For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
#RangeMap: { #RangeMap: {
type: #MappingType & "range" type: #MappingType & "range"
// Range to match against and the result to apply when the value is within the range
options: { options: {
// to and from are `number | null` in current ts, really not sure what to do // Min value of the range. It can be null which means -Infinity
from: float64 @grafanamaturity(NeedsExpertReview) from: float64
to: float64 @grafanamaturity(NeedsExpertReview) // Max value of the range. It can be null which means +Infinity
to: float64
// Config to apply when the value is within the range
result: #ValueMappingResult
}
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
// Maps regular expressions to replacement text and a color.
// For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
#RegexMap: {
type: #MappingType & "regex"
// Regular expression to match against and the result to apply when the value matches the regex
options: {
// Regular expression to match against
pattern: string
// Config to apply when the value matches the regex
result: #ValueMappingResult result: #ValueMappingResult
} }
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview)
// Maps regular expressions to replacement text and a color // Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color.
#RegexMap: { // See SpecialValueMatch to see the list of special values.
type: #MappingType & "regex" // For example, you can configure a special value mapping so that null values appear as N/A.
options: {
pattern: string
result: #ValueMappingResult
}
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview)
// Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text
// and color
#SpecialValueMap: { #SpecialValueMap: {
type: #MappingType & "special" type: #MappingType & "special"
options: { options: {
match: "true" | "false" // Special value to match against
pattern: string match: #SpecialValueMatch
result: #ValueMappingResult // Config to apply when the value matches the special value
result: #ValueMappingResult
} }
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview)
// Special value types supported by the SpecialValueMap // Special value types supported by the `SpecialValueMap`
#SpecialValueMatch: "true" | "false" | "null" | "nan" | "null+nan" | "empty" @cuetsy(kind="enum",memberNames="True|False|Null|NaN|NullAndNan|Empty") #SpecialValueMatch: "true" | "false" | "null" | "nan" | "null+nan" | "empty" @cuetsy(kind="enum",memberNames="True|False|Null|NaN|NullAndNan|Empty")
// Result used as replacement text and color for RegexMap and SpecialValueMap // Result used as replacement with text and color when the value matches
#ValueMappingResult: { #ValueMappingResult: {
text?: string // Text to display when the value matches
text?: string
// Text to use when the value matches
color?: string color?: string
icon?: string // Icon to display when the value matches. Only specific visualizations.
icon?: string
// Position in the mapping array. Only used internally.
index?: int32 index?: int32
} @cuetsy(kind="interface") } @cuetsy(kind="interface")
// TODO docs // Transformations allow to manipulate data returned by a query before the system applies a visualization.
// Using transformations you can: rename fields, join time series data, perform mathematical operations across queries,
// use the output of one transformation as the input to another transformation, etc.
#DataTransformerConfig: { #DataTransformerConfig: {
@grafana(TSVeneer="type")
// Unique identifier of transformer // Unique identifier of transformer
id: string id: string
// Disabled transformations are skipped // Disabled transformations are skipped
disabled?: bool disabled?: bool
// Optional frame matcher. When missing it will be applied to all results // Optional frame matcher. When missing it will be applied to all results
filter?: #MatcherConfig filter?: #MatcherConfig
// Options to be passed to the transformer // Options to be passed to the transformer
// Valid options depend on the transformer id // Valid options depend on the transformer id
options: _ options: _
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface") @grafana(TSVeneer="type")
// 0 for no shared crosshair or tooltip (default). // 0 for no shared crosshair or tooltip (default).
// 1 for shared crosshair. // 1 for shared crosshair.
@ -369,7 +471,7 @@ lineage: schemas: [{
// with types derived from plugins in the Instance variant. // with types derived from plugins in the Instance variant.
// When working directly from CUE, importers can extend this // When working directly from CUE, importers can extend this
// type directly to achieve the same effect. // type directly to achieve the same effect.
#Target: {...} @grafanamaturity(NeedsExpertReview) #Target: {...}
// A dashboard snapshot shares an interactive dashboard publicly. // A dashboard snapshot shares an interactive dashboard publicly.
// It is a read-only version of a dashboard, and is not editable. // It is a read-only version of a dashboard, and is not editable.
@ -401,61 +503,58 @@ lineage: schemas: [{
userId: uint32 @grafanamaturity(NeedsExpertReview) userId: uint32 @grafanamaturity(NeedsExpertReview)
} @grafanamaturity(NeedsExpertReview) } @grafanamaturity(NeedsExpertReview)
// Dashboard panels. Panels are canonically defined inline // Dashboard panels are the basic visualization building blocks.
// because they share a version timeline with the dashboard
// schema; they do not evolve independently.
#Panel: { #Panel: {
// The panel plugin type id. May not be empty. // The panel plugin type id. This is used to find the plugin to display the panel.
type: string & strings.MinRunes(1) @grafanamaturity(NeedsExpertReview) type: string & strings.MinRunes(1)
// TODO docs // Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
id?: uint32 @grafanamaturity(NeedsExpertReview) id?: uint32
// FIXME this almost certainly has to be changed in favor of scuemata versions // The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
pluginVersion?: string @grafanamaturity(NeedsExpertReview) pluginVersion?: string
// TODO docs // Tags for the panel.
tags?: [...string] @grafanamaturity(NeedsExpertReview) tags?: [...string]
// TODO docs // Depends on the panel plugin. See the plugin documentation for details.
targets?: [...#Target] @grafanamaturity(NeedsExpertReview) targets?: [...#Target]
// Panel title. // Panel title.
title?: string @grafanamaturity(NeedsExpertReview) title?: string
// Description.
description?: string @grafanamaturity(NeedsExpertReview) // Panel description.
description?: string
// Whether to display the panel without a background. // Whether to display the panel without a background.
transparent: bool | *false @grafanamaturity(NeedsExpertReview) transparent: bool | *false
// The datasource used in all targets. // The datasource used in all targets.
datasource?: { datasource?: #DataSourceRef
type?: string
uid?: string
} @grafanamaturity(NeedsExpertReview)
// Grid position. // Grid position.
gridPos?: #GridPos gridPos?: #GridPos
// Panel links. // Panel links.
// TODO fill this out - seems there are a couple variants? links?: [...#DashboardLink]
links?: [...#DashboardLink] @grafanamaturity(NeedsExpertReview)
// Name of template variable to repeat for. // Name of template variable to repeat for.
repeat?: string @grafanamaturity(NeedsExpertReview) repeat?: string
// Direction to repeat in if 'repeat' is set. // Direction to repeat in if 'repeat' is set.
// "h" for horizontal, "v" for vertical. // `h` for horizontal, `v` for vertical.
// TODO this is probably optional repeatDirection?: *"h" | "v"
repeatDirection: *"h" | "v" @grafanamaturity(NeedsExpertReview)
// Id of the repeating panel. // Id of the repeating panel.
repeatPanelId?: int64 @grafanamaturity(NeedsExpertReview) repeatPanelId?: int64
// The maximum number of data points that the panel queries are retrieving. // The maximum number of data points that the panel queries are retrieving.
maxDataPoints?: number maxDataPoints?: number
// TODO docs - seems to be an old field from old dashboard alerts? // List of transformations that are applied to the panel data before rendering.
thresholds?: [...] @grafanamaturity(NeedsExpertReview) // When there are multiple transformations, Grafana applies them in the order they are listed.
// Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.
// TODO docs transformations: [...#DataTransformerConfig]
timeRegions?: [...] @grafanamaturity(NeedsExpertReview)
transformations: [...#DataTransformerConfig] @grafanamaturity(NeedsExpertReview)
// The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables. // The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.
// This value must be formatted as a number followed by a valid time // This value must be formatted as a number followed by a valid time
@ -482,29 +581,43 @@ lineage: schemas: [{
// Dynamically load the panel // Dynamically load the panel
libraryPanel?: #LibraryPanelRef libraryPanel?: #LibraryPanelRef
// options is specified by the Options field in panel // It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
// plugin schemas.
options: {...} @grafanamaturity(NeedsExpertReview) options: {...} @grafanamaturity(NeedsExpertReview)
// Field options allow you to change how the data is displayed in your visualizations.
fieldConfig: #FieldConfigSource fieldConfig: #FieldConfigSource
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
#FieldConfigSource: { #FieldConfigSource: {
// Defaults are the options applied to all fields.
defaults: #FieldConfig defaults: #FieldConfig
// Overrides are the options applied to specific fields overriding the defaults.
overrides: [...{ overrides: [...{
matcher: #MatcherConfig matcher: #MatcherConfig
properties: [...#DynamicConfigValue] properties: [...#DynamicConfigValue]
}] @grafanamaturity(NeedsExpertReview) }] @grafanamaturity(NeedsExpertReview)
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
// A library panel is a reusable panel that you can use in any dashboard.
// When you make a change to a library panel, that change propagates to all instances of where the panel is used.
// Library panels streamline reuse of panels across multiple dashboards.
#LibraryPanelRef: { #LibraryPanelRef: {
// Library panel name
name: string name: string
uid: string // Library panel uid
uid: string
} @cuetsy(kind="interface") } @cuetsy(kind="interface")
// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
// It comes with in id ( to resolve implementation from registry) and a configuration thats specific to a particular matcher type.
#MatcherConfig: { #MatcherConfig: {
id: string | *"" @grafanamaturity(NeedsExpertReview) // The matcher id. This is used to find the matcher implementation from registry.
options?: _ @grafanamaturity(NeedsExpertReview) id: string | *"" @grafanamaturity(NeedsExpertReview)
// The matcher options. This is specific to the matcher implementation.
options?: _ @grafanamaturity(NeedsExpertReview)
} @cuetsy(kind="interface") @grafana(TSVeneer="type") } @cuetsy(kind="interface") @grafana(TSVeneer="type")
#DynamicConfigValue: { #DynamicConfigValue: {
@ -512,6 +625,9 @@ lineage: schemas: [{
value?: _ @grafanamaturity(NeedsExpertReview) value?: _ @grafanamaturity(NeedsExpertReview)
} }
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
#FieldConfig: { #FieldConfig: {
// The display value for this field. This supports template variables blank is auto // The display value for this field. This supports template variables blank is auto
displayName?: string @grafanamaturity(NeedsExpertReview) displayName?: string @grafanamaturity(NeedsExpertReview)
@ -530,19 +646,33 @@ lineage: schemas: [{
// may be used to update the results // may be used to update the results
path?: string @grafanamaturity(NeedsExpertReview) path?: string @grafanamaturity(NeedsExpertReview)
// True if data source can write a value to the path. Auth/authz are supported separately // True if data source can write a value to the path. Auth/authz are supported separately
writeable?: bool @grafanamaturity(NeedsExpertReview) writeable?: bool @grafanamaturity(NeedsExpertReview)
// True if data source field supports ad-hoc filters // True if data source field supports ad-hoc filters
filterable?: bool @grafanamaturity(NeedsExpertReview) filterable?: bool @grafanamaturity(NeedsExpertReview)
// Numeric Options // Unit a field should use. The unit you select is applied to all fields except time.
// You can use the units ID availables in Grafana or a custom unit.
// Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts
// As custom unit, you can use the following formats:
// `suffix:<suffix>` for custom unit that should go after value.
// `prefix:<prefix>` for custom unit that should go before value.
// `time:<format>` For custom date time formats type for example `time:YYYY-MM-DD`.
// `si:<base scale><unit characters>` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character.
// `count:<unit>` for a custom count unit.
// `currency:<unit>` for custom a currency unit.
unit?: string @grafanamaturity(NeedsExpertReview) unit?: string @grafanamaturity(NeedsExpertReview)
// Significant digits (for display) // Specify the number of decimals Grafana includes in the rendered value.
// If you leave this field blank, Grafana automatically truncates the number of decimals based on the value.
// For example 1.1234 will display as 1.12 and 100.456 will display as 100.
// To display all decimals, set the unit to `String`.
decimals?: number @grafanamaturity(NeedsExpertReview) decimals?: number @grafanamaturity(NeedsExpertReview)
// The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
min?: number @grafanamaturity(NeedsExpertReview) min?: number @grafanamaturity(NeedsExpertReview)
// The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
max?: number @grafanamaturity(NeedsExpertReview) max?: number @grafanamaturity(NeedsExpertReview)
// Convert input values into a display string // Convert input values into a display string
@ -551,11 +681,8 @@ lineage: schemas: [{
// Map numeric values to states // Map numeric values to states
thresholds?: #ThresholdsConfig @grafanamaturity(NeedsExpertReview) thresholds?: #ThresholdsConfig @grafanamaturity(NeedsExpertReview)
// Map values to a display color // Panel color configuration
color?: #FieldColor @grafanamaturity(NeedsExpertReview) color?: #FieldColor
// Used when reducing field values
// nullValueMode?: NullValueMode
// The behavior when clicking on a result // The behavior when clicking on a result
links?: [...] @grafanamaturity(NeedsExpertReview) links?: [...] @grafanamaturity(NeedsExpertReview)
@ -570,26 +697,35 @@ lineage: schemas: [{
// Row panel // Row panel
#RowPanel: { #RowPanel: {
type: "row" @grafanamaturity(NeedsExpertReview) // The panel type
collapsed: bool | *false @grafanamaturity(NeedsExpertReview) type: "row"
title?: string @grafanamaturity(NeedsExpertReview)
// Name of default datasource. // Whether this row should be collapsed or not.
datasource?: { collapsed: bool | *false
type?: string @grafanamaturity(NeedsExpertReview)
uid?: string @grafanamaturity(NeedsExpertReview)
} @grafanamaturity(NeedsExpertReview)
// Row title
title?: string
// Name of default datasource for the row
datasource?: #DataSourceRef
// Row grid position
gridPos?: #GridPos gridPos?: #GridPos
id: uint32 @grafanamaturity(NeedsExpertReview)
panels: [...(#Panel | #GraphPanel | #HeatmapPanel)] @grafanamaturity(NeedsExpertReview)
// Name of template variable to repeat for.
repeat?: string @grafanamaturity(NeedsExpertReview)
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview)
// Support for legacy graph and heatmap panels. // Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
id: uint32
// List of panels in the row
panels: [...(#Panel | #GraphPanel | #HeatmapPanel)]
// Name of template variable to repeat for.
repeat?: string
} @cuetsy(kind="interface") @grafana(TSVeneer="type")
// Support for legacy graph panel.
// @deprecated this a deprecated panel type
#GraphPanel: { #GraphPanel: {
type: "graph" @grafanamaturity(NeedsExpertReview) type: "graph"
// @deprecated this is part of deprecated graph panel // @deprecated this is part of deprecated graph panel
legend?: { legend?: {
show: bool | *true show: bool | *true
@ -597,12 +733,14 @@ lineage: schemas: [{
sortDesc?: bool sortDesc?: bool
} }
... ...
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface")
// Support for legacy heatmap panel.
// @deprecated this a deprecated panel type
#HeatmapPanel: { #HeatmapPanel: {
type: "heatmap" @grafanamaturity(NeedsExpertReview) type: "heatmap"
... ...
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview) } @cuetsy(kind="interface")
} }
}, },
] ]

View File

@ -22,22 +22,18 @@ export { defaultAccessPolicy } from './raw/accesspolicy/x/accesspolicy_types.gen
export type { export type {
AnnotationTarget, AnnotationTarget,
AnnotationPanelFilter, AnnotationPanelFilter,
VariableOption,
DashboardLink, DashboardLink,
DashboardLinkType, DashboardLinkType,
VariableType, VariableType,
FieldColorSeriesByMode, FieldColorSeriesByMode,
FieldColor, FieldColor,
GridPos, GridPos,
Threshold,
ThresholdsConfig,
ValueMapping,
ValueMap, ValueMap,
RangeMap,
RegexMap, RegexMap,
SpecialValueMap, SpecialValueMap,
ValueMappingResult, ValueMappingResult,
LibraryPanelRef, LibraryPanelRef,
RowPanel,
GraphPanel, GraphPanel,
HeatmapPanel HeatmapPanel
} from './raw/dashboard/x/dashboard_types.gen'; } from './raw/dashboard/x/dashboard_types.gen';
@ -46,17 +42,17 @@ export type {
export { export {
defaultAnnotationTarget, defaultAnnotationTarget,
defaultAnnotationPanelFilter, defaultAnnotationPanelFilter,
VariableRefresh,
VariableSort,
LoadingState, LoadingState,
defaultDashboardLink, defaultDashboardLink,
FieldColorModeId, FieldColorModeId,
defaultGridPos, defaultGridPos,
ThresholdsMode, ThresholdsMode,
defaultThresholdsConfig,
MappingType, MappingType,
SpecialValueMatch, SpecialValueMatch,
DashboardCursorSync, DashboardCursorSync,
defaultDashboardCursorSync, defaultDashboardCursorSync
defaultRowPanel
} from './raw/dashboard/x/dashboard_types.gen'; } from './raw/dashboard/x/dashboard_types.gen';
// The following exported declarations correspond to types in the dashboard@0.0 kind's // The following exported declarations correspond to types in the dashboard@0.0 kind's
@ -74,11 +70,16 @@ export type {
AnnotationQuery, AnnotationQuery,
VariableModel, VariableModel,
DataSourceRef, DataSourceRef,
Threshold,
ThresholdsConfig,
ValueMapping,
RangeMap,
DataTransformerConfig, DataTransformerConfig,
Panel, Panel,
FieldConfigSource, FieldConfigSource,
MatcherConfig, MatcherConfig,
FieldConfig FieldConfig,
RowPanel
} from './veneer/dashboard.types'; } from './veneer/dashboard.types';
// The following exported declarations correspond to types in the dashboard@0.0 kind's // The following exported declarations correspond to types in the dashboard@0.0 kind's
@ -96,10 +97,12 @@ export {
defaultAnnotationQuery, defaultAnnotationQuery,
defaultVariableModel, defaultVariableModel,
VariableHide, VariableHide,
defaultThresholdsConfig,
defaultPanel, defaultPanel,
defaultFieldConfigSource, defaultFieldConfigSource,
defaultMatcherConfig, defaultMatcherConfig,
defaultFieldConfig defaultFieldConfig,
defaultRowPanel
} from './veneer/dashboard.types'; } from './veneer/dashboard.types';
// Raw generated types from Folder kind. // Raw generated types from Folder kind.

View File

@ -56,9 +56,15 @@ export const defaultAnnotationPanelFilter: Partial<AnnotationPanelFilter> = {
}; };
/** /**
* TODO -- should not be a public interface on its own, but required for Veneer * Contains the list of annotations that are associated with the dashboard.
* Annotations are used to overlay event markers and overlay event tags on graphs.
* Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
* See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
*/ */
export interface AnnotationContainer { export interface AnnotationContainer {
/**
* List of annotations
*/
list?: Array<AnnotationQuery>; list?: Array<AnnotationQuery>;
} }
@ -111,6 +117,137 @@ export const defaultAnnotationQuery: Partial<AnnotationQuery> = {
hide: false, hide: false,
}; };
/**
* A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
*/
export interface VariableModel {
/**
* Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc.
*/
allFormat?: string;
/**
* Shows current selected variable text/value on the dashboard
*/
current?: VariableOption;
/**
* Data source used to fetch values for a variable. It can be defined but `null`.
*/
datasource?: DataSourceRef;
/**
* Description of variable. It can be defined but `null`.
*/
description?: string;
/**
* Visibility configuration for the variable
*/
hide: VariableHide;
/**
* Unique numeric identifier for the variable.
*/
id: string;
/**
* Optional display name
*/
label?: string;
/**
* Whether multiple values can be selected or not from variable value list
*/
multi?: boolean;
/**
* Name of variable
*/
name: string;
/**
* Options that can be selected for a variable.
*/
options?: Array<VariableOption>;
/**
* Query used to fetch values for a variable
*/
query?: (string | Record<string, unknown>);
refresh?: VariableRefresh;
/**
* Whether the variable value should be managed by URL query params or not
*/
skipUrlSync: boolean;
/**
* Type of variable
*/
type: VariableType;
}
export const defaultVariableModel: Partial<VariableModel> = {
id: '00000000-0000-0000-0000-000000000000',
multi: false,
options: [],
skipUrlSync: false,
};
/**
* Option to be selected in a variable.
*/
export interface VariableOption {
/**
* Whether the option is selected or not
*/
selected?: boolean;
/**
* Text to be displayed for the option
*/
text: (string | Array<string>);
/**
* Value of the option
*/
value: (string | Array<string>);
}
/**
* Options to config when to refresh a variable
* `0`: Never refresh the variable
* `1`: Queries the data source every time the dashboard loads.
* `2`: Queries the data source when the dashboard time range changes.
*/
export enum VariableRefresh {
never = 0,
onDashboardLoad = 1,
onTimeRangeChanged = 2,
}
/**
* Determine if the variable shows on dashboard
* Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
*/
export enum VariableHide {
dontHide = 0,
hideLabel = 1,
hideVariable = 2,
}
/**
* Sort variable options
* Accepted values are:
* `0`: No sorting
* `1`: Alphabetical ASC
* `2`: Alphabetical DESC
* `3`: Numerical ASC
* `4`: Numerical DESC
* `5`: Alphabetical Case Insensitive ASC
* `6`: Alphabetical Case Insensitive DESC
*/
export enum VariableSort {
alphabeticalAsc = 1,
alphabeticalCaseInsensitiveAsc = 5,
alphabeticalCaseInsensitiveDesc = 6,
alphabeticalDesc = 2,
disabled = 0,
numericalAsc = 3,
numericalDesc = 4,
}
/**
* Loading status
* Accepted values are `NotStarted` (the request is not started), `Loading` (waiting for response), `Streaming` (pulling continuous data), `Done` (response received successfully) or `Error` (failed request).
*/
export enum LoadingState { export enum LoadingState {
Done = 'Done', Done = 'Done',
Error = 'Error', Error = 'Error',
@ -119,45 +256,6 @@ export enum LoadingState {
Streaming = 'Streaming', Streaming = 'Streaming',
} }
/**
* FROM: packages/grafana-data/src/types/templateVars.ts
* TODO docs
* TODO what about what's in public/app/features/types.ts?
* TODO there appear to be a lot of different kinds of [template] vars here? if so need a disjunction
*/
export interface VariableModel {
datasource?: DataSourceRef;
description?: string;
error?: Record<string, unknown>;
global: boolean;
hide: VariableHide;
id: string;
index: number;
label?: string;
name: string;
/**
* TODO: Move this into a separated QueryVariableModel type
*/
query?: (string | Record<string, unknown>);
rootStateKey?: string;
skipUrlSync: boolean;
state: LoadingState;
type: VariableType;
}
export const defaultVariableModel: Partial<VariableModel> = {
global: false,
id: '00000000-0000-0000-0000-000000000000',
index: -1,
skipUrlSync: false,
};
export enum VariableHide {
dontHide = 0,
hideLabel = 1,
hideVariable = 2,
}
/** /**
* Ref to a DataSource instance * Ref to a DataSource instance
*/ */
@ -232,65 +330,101 @@ export const defaultDashboardLink: Partial<DashboardLink> = {
export type DashboardLinkType = ('link' | 'dashboards'); export type DashboardLinkType = ('link' | 'dashboards');
/** /**
* FROM: packages/grafana-data/src/types/templateVars.ts * Dashboard variable type
* TODO docs * `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
* TODO this implies some wider pattern/discriminated union, probably? * `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
* `constant`: Define a hidden constant.
* `datasource`: Quickly change the data source for an entire dashboard.
* `interval`: Interval variables represent time spans.
* `textbox`: Display a free text input field with an optional default value.
* `custom`: Define the variable options manually using a comma-separated list.
* `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
*/ */
export type VariableType = ('query' | 'adhoc' | 'constant' | 'datasource' | 'interval' | 'textbox' | 'custom' | 'system'); export type VariableType = ('query' | 'adhoc' | 'constant' | 'datasource' | 'interval' | 'textbox' | 'custom' | 'system');
/** /**
* TODO docs * Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.
* Continuous color interpolates a color using the percentage of a value relative to min and max.
* Accepted values are:
* `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold
* `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations
* `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations
* `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode
* `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode
* `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode
* `continuous-YlRd`: Continuous Yellow-Red palette mode
* `continuous-BlPu`: Continuous Blue-Purple palette mode
* `continuous-YlBl`: Continuous Yellow-Blue palette mode
* `continuous-blues`: Continuous Blue palette mode
* `continuous-reds`: Continuous Red palette mode
* `continuous-greens`: Continuous Green palette mode
* `continuous-purples`: Continuous Purple palette mode
* `shades`: Shades of a single color. Specify a single color, useful in an override rule.
* `fixed`: Fixed color mode. Specify a single color, useful in an override rule.
*/ */
export enum FieldColorModeId { export enum FieldColorModeId {
ContinuousBlPu = 'continuous-BlPu',
ContinuousBlYlRd = 'continuous-BlYlRd',
ContinuousBlues = 'continuous-blues',
ContinuousGrYlRd = 'continuous-GrYlRd', ContinuousGrYlRd = 'continuous-GrYlRd',
ContinuousGreens = 'continuous-greens',
ContinuousPurples = 'continuous-purples',
ContinuousRdYlGr = 'continuous-RdYlGr',
ContinuousReds = 'continuous-reds',
ContinuousYlBl = 'continuous-YlBl',
ContinuousYlRd = 'continuous-YlRd',
Fixed = 'fixed', Fixed = 'fixed',
PaletteClassic = 'palette-classic', PaletteClassic = 'palette-classic',
PaletteSaturated = 'palette-saturated', PaletteClassicByName = 'palette-classic-by-name',
Shades = 'shades',
Thresholds = 'thresholds', Thresholds = 'thresholds',
} }
/** /**
* TODO docs * Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.
*/ */
export type FieldColorSeriesByMode = ('min' | 'max' | 'last'); export type FieldColorSeriesByMode = ('min' | 'max' | 'last');
/** /**
* TODO docs * Map a field to a color.
*/ */
export interface FieldColor { export interface FieldColor {
/** /**
* Stores the fixed color value if mode is fixed * The fixed color value for fixed or shades color modes.
*/ */
fixedColor?: string; fixedColor?: string;
/** /**
* The main color scheme mode * The main color scheme mode.
*/ */
mode: (FieldColorModeId | string); mode: FieldColorModeId;
/** /**
* Some visualizations need to know how to assign a series color from by value color schemes * Some visualizations need to know how to assign a series color from by value color schemes.
*/ */
seriesBy?: FieldColorSeriesByMode; seriesBy?: FieldColorSeriesByMode;
} }
/**
* Position and dimensions of a panel in the grid
*/
export interface GridPos { export interface GridPos {
/** /**
* Panel * Panel height. The height is the number of rows from the top edge of the panel.
*/ */
h: number; h: number;
/** /**
* Whether the panel is fixed within the grid * Whether the panel is fixed within the grid. If true, the panel will not be affected by other panels' interactions
*/ */
static?: boolean; static?: boolean;
/** /**
* Panel * Panel width. The width is the number of columns from the left edge of the panel.
*/ */
w: number; w: number;
/** /**
* Panel x * Panel x. The x coordinate is the number of columns from the left edge of the grid
*/ */
x: number; x: number;
/** /**
* Panel y * Panel y. The y coordinate is the number of rows from the top edge of the grid
*/ */
y: number; y: number;
} }
@ -311,32 +445,28 @@ export interface Threshold {
* Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded. * Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded.
*/ */
color: string; color: string;
/**
* Threshold index, an old property that is not needed an should only appear in older dashboards
*/
index?: number;
/**
* TODO docs
* TODO are the values here enumerable into a disjunction?
* Some seem to be listed in typescript comment
*/
state?: string;
/** /**
* Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded. * Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded.
* FIXME the corresponding typescript field is required/non-optional, but nulls currently appear here when serializing -Infinity to JSON * Nulls currently appear here when serializing -Infinity to JSON.
*/ */
value?: number; value: number;
} }
/** /**
* Thresholds can either be absolute (specific number) or percentage (relative to min or max). * Thresholds can either be `absolute` (specific number) or `percentage` (relative to min or max, it will be values between 0 and 1).
*/ */
export enum ThresholdsMode { export enum ThresholdsMode {
Absolute = 'absolute', Absolute = 'absolute',
Percentage = 'percentage', Percentage = 'percentage',
} }
/**
* Thresholds configuration for the panel
*/
export interface ThresholdsConfig { export interface ThresholdsConfig {
/**
* Thresholds mode.
*/
mode: ThresholdsMode; mode: ThresholdsMode;
/** /**
* Must be sorted by 'value', first value is always -Infinity * Must be sorted by 'value', first value is always -Infinity
@ -355,6 +485,10 @@ export type ValueMapping = (ValueMap | RangeMap | RegexMap | SpecialValueMap);
/** /**
* Supported value mapping types * Supported value mapping types
* `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
* `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
* `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
* `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A.
*/ */
export enum MappingType { export enum MappingType {
RangeToText = 'range', RangeToText = 'range',
@ -364,54 +498,84 @@ export enum MappingType {
} }
/** /**
* Maps text values to a color or different display text * Maps text values to a color or different display text and color.
* For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
*/ */
export interface ValueMap { export interface ValueMap {
/**
* Map with <value_to_match>: ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } }
*/
options: Record<string, ValueMappingResult>; options: Record<string, ValueMappingResult>;
type: MappingType.ValueToText; type: MappingType.ValueToText;
} }
/** /**
* Maps numeric ranges to a color or different display text * Maps numerical ranges to a display text and color.
* For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
*/ */
export interface RangeMap { export interface RangeMap {
/**
* Range to match against and the result to apply when the value is within the range
*/
options: { options: {
/** /**
* to and from are `number | null` in current ts, really not sure what to do * Min value of the range. It can be null which means -Infinity
*/ */
from: number; from: number;
/**
* Max value of the range. It can be null which means +Infinity
*/
to: number; to: number;
/**
* Config to apply when the value is within the range
*/
result: ValueMappingResult; result: ValueMappingResult;
}; };
type: MappingType.RangeToText; type: MappingType.RangeToText;
} }
/** /**
* Maps regular expressions to replacement text and a color * Maps regular expressions to replacement text and a color.
* For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
*/ */
export interface RegexMap { export interface RegexMap {
/**
* Regular expression to match against and the result to apply when the value matches the regex
*/
options: { options: {
/**
* Regular expression to match against
*/
pattern: string; pattern: string;
/**
* Config to apply when the value matches the regex
*/
result: ValueMappingResult; result: ValueMappingResult;
}; };
type: MappingType.RegexToText; type: MappingType.RegexToText;
} }
/** /**
* Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text * Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color.
* and color * See SpecialValueMatch to see the list of special values.
* For example, you can configure a special value mapping so that null values appear as N/A.
*/ */
export interface SpecialValueMap { export interface SpecialValueMap {
options: { options: {
match: ('true' | 'false'); /**
pattern: string; * Special value to match against
*/
match: SpecialValueMatch;
/**
* Config to apply when the value matches the special value
*/
result: ValueMappingResult; result: ValueMappingResult;
}; };
type: MappingType.SpecialValue; type: MappingType.SpecialValue;
} }
/** /**
* Special value types supported by the SpecialValueMap * Special value types supported by the `SpecialValueMap`
*/ */
export enum SpecialValueMatch { export enum SpecialValueMatch {
Empty = 'empty', Empty = 'empty',
@ -423,17 +587,31 @@ export enum SpecialValueMatch {
} }
/** /**
* Result used as replacement text and color for RegexMap and SpecialValueMap * Result used as replacement with text and color when the value matches
*/ */
export interface ValueMappingResult { export interface ValueMappingResult {
/**
* Text to use when the value matches
*/
color?: string; color?: string;
/**
* Icon to display when the value matches. Only specific visualizations.
*/
icon?: string; icon?: string;
/**
* Position in the mapping array. Only used internally.
*/
index?: number; index?: number;
/**
* Text to display when the value matches
*/
text?: string; text?: string;
} }
/** /**
* TODO docs * Transformations allow to manipulate data returned by a query before the system applies a visualization.
* Using transformations you can: rename fields, join time series data, perform mathematical operations across queries,
* use the output of one transformation as the input to another transformation, etc.
*/ */
export interface DataTransformerConfig { export interface DataTransformerConfig {
/** /**
@ -441,7 +619,7 @@ export interface DataTransformerConfig {
*/ */
disabled?: boolean; disabled?: boolean;
/** /**
* Optional frame matcher. When missing it will be applied to all results * Optional frame matcher. When missing it will be applied to all results
*/ */
filter?: MatcherConfig; filter?: MatcherConfig;
/** /**
@ -469,29 +647,27 @@ export enum DashboardCursorSync {
export const defaultDashboardCursorSync: DashboardCursorSync = DashboardCursorSync.Off; export const defaultDashboardCursorSync: DashboardCursorSync = DashboardCursorSync.Off;
/** /**
* Dashboard panels. Panels are canonically defined inline * Dashboard panels are the basic visualization building blocks.
* because they share a version timeline with the dashboard
* schema; they do not evolve independently.
*/ */
export interface Panel { export interface Panel {
/** /**
* The datasource used in all targets. * The datasource used in all targets.
*/ */
datasource?: { datasource?: DataSourceRef;
type?: string;
uid?: string;
};
/** /**
* Description. * Panel description.
*/ */
description?: string; description?: string;
/**
* Field options allow you to change how the data is displayed in your visualizations.
*/
fieldConfig: FieldConfigSource; fieldConfig: FieldConfigSource;
/** /**
* Grid position. * Grid position.
*/ */
gridPos?: GridPos; gridPos?: GridPos;
/** /**
* TODO docs * Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
*/ */
id?: number; id?: number;
/** /**
@ -507,7 +683,6 @@ export interface Panel {
libraryPanel?: LibraryPanelRef; libraryPanel?: LibraryPanelRef;
/** /**
* Panel links. * Panel links.
* TODO fill this out - seems there are a couple variants?
*/ */
links?: Array<DashboardLink>; links?: Array<DashboardLink>;
/** /**
@ -515,12 +690,11 @@ export interface Panel {
*/ */
maxDataPoints?: number; maxDataPoints?: number;
/** /**
* options is specified by the Options field in panel * It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
* plugin schemas.
*/ */
options: Record<string, unknown>; options: Record<string, unknown>;
/** /**
* FIXME this almost certainly has to be changed in favor of scuemata versions * The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
*/ */
pluginVersion?: string; pluginVersion?: string;
/** /**
@ -529,26 +703,21 @@ export interface Panel {
repeat?: string; repeat?: string;
/** /**
* Direction to repeat in if 'repeat' is set. * Direction to repeat in if 'repeat' is set.
* "h" for horizontal, "v" for vertical. * `h` for horizontal, `v` for vertical.
* TODO this is probably optional
*/ */
repeatDirection: ('h' | 'v'); repeatDirection?: ('h' | 'v');
/** /**
* Id of the repeating panel. * Id of the repeating panel.
*/ */
repeatPanelId?: number; repeatPanelId?: number;
/** /**
* TODO docs * Tags for the panel.
*/ */
tags?: Array<string>; tags?: Array<string>;
/** /**
* TODO docs * Depends on the panel plugin. See the plugin documentation for details.
*/ */
targets?: Array<Record<string, unknown>>; targets?: Array<Record<string, unknown>>;
/**
* TODO docs - seems to be an old field from old dashboard alerts?
*/
thresholds?: Array<unknown>;
/** /**
* Overrides the relative time range for individual panels, * Overrides the relative time range for individual panels,
* which causes them to be different than what is selected in * which causes them to be different than what is selected in
@ -560,10 +729,6 @@ export interface Panel {
* See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options * See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
*/ */
timeFrom?: string; timeFrom?: string;
/**
* TODO docs
*/
timeRegions?: Array<unknown>;
/** /**
* Overrides the time range for individual panels by shifting its start and end relative to the time picker. * Overrides the time range for individual panels by shifting its start and end relative to the time picker.
* For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`. * For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.
@ -575,13 +740,18 @@ export interface Panel {
* Panel title. * Panel title.
*/ */
title?: string; title?: string;
/**
* List of transformations that are applied to the panel data before rendering.
* When there are multiple transformations, Grafana applies them in the order they are listed.
* Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.
*/
transformations: Array<DataTransformerConfig>; transformations: Array<DataTransformerConfig>;
/** /**
* Whether to display the panel without a background. * Whether to display the panel without a background.
*/ */
transparent: boolean; transparent: boolean;
/** /**
* The panel plugin type id. May not be empty. * The panel plugin type id. This is used to find the plugin to display the panel.
*/ */
type: string; type: string;
} }
@ -591,14 +761,23 @@ export const defaultPanel: Partial<Panel> = {
repeatDirection: 'h', repeatDirection: 'h',
tags: [], tags: [],
targets: [], targets: [],
thresholds: [],
timeRegions: [],
transformations: [], transformations: [],
transparent: false, transparent: false,
}; };
/**
* The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
* Each column within this structure is called a field. A field can represent a single time series or table column.
* Field options allow you to change how the data is displayed in your visualizations.
*/
export interface FieldConfigSource { export interface FieldConfigSource {
/**
* Defaults are the options applied to all fields.
*/
defaults: FieldConfig; defaults: FieldConfig;
/**
* Overrides are the options applied to specific fields overriding the defaults.
*/
overrides: Array<{ overrides: Array<{
matcher: MatcherConfig; matcher: MatcherConfig;
properties: Array<{ properties: Array<{
@ -612,13 +791,34 @@ export const defaultFieldConfigSource: Partial<FieldConfigSource> = {
overrides: [], overrides: [],
}; };
/**
* A library panel is a reusable panel that you can use in any dashboard.
* When you make a change to a library panel, that change propagates to all instances of where the panel is used.
* Library panels streamline reuse of panels across multiple dashboards.
*/
export interface LibraryPanelRef { export interface LibraryPanelRef {
/**
* Library panel name
*/
name: string; name: string;
/**
* Library panel uid
*/
uid: string; uid: string;
} }
/**
* Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
* It comes with in id ( to resolve implementation from registry) and a configuration thats specific to a particular matcher type.
*/
export interface MatcherConfig { export interface MatcherConfig {
/**
* The matcher id. This is used to find the matcher implementation from registry.
*/
id: string; id: string;
/**
* The matcher options. This is specific to the matcher implementation.
*/
options?: unknown; options?: unknown;
} }
@ -626,9 +826,14 @@ export const defaultMatcherConfig: Partial<MatcherConfig> = {
id: '', id: '',
}; };
/**
* The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
* Each column within this structure is called a field. A field can represent a single time series or table column.
* Field options allow you to change how the data is displayed in your visualizations.
*/
export interface FieldConfig { export interface FieldConfig {
/** /**
* Map values to a display color * Panel color configuration
*/ */
color?: FieldColor; color?: FieldColor;
/** /**
@ -637,7 +842,10 @@ export interface FieldConfig {
*/ */
custom?: Record<string, unknown>; custom?: Record<string, unknown>;
/** /**
* Significant digits (for display) * Specify the number of decimals Grafana includes in the rendered value.
* If you leave this field blank, Grafana automatically truncates the number of decimals based on the value.
* For example 1.1234 will display as 1.12 and 100.456 will display as 100.
* To display all decimals, set the unit to `String`.
*/ */
decimals?: number; decimals?: number;
/** /**
@ -665,7 +873,13 @@ export interface FieldConfig {
* Convert input values into a display string * Convert input values into a display string
*/ */
mappings?: Array<ValueMapping>; mappings?: Array<ValueMapping>;
/**
* The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
*/
max?: number; max?: number;
/**
* The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
*/
min?: number; min?: number;
/** /**
* Alternative to empty string * Alternative to empty string
@ -684,11 +898,20 @@ export interface FieldConfig {
*/ */
thresholds?: ThresholdsConfig; thresholds?: ThresholdsConfig;
/** /**
* Numeric Options * Unit a field should use. The unit you select is applied to all fields except time.
* You can use the units ID availables in Grafana or a custom unit.
* Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts
* As custom unit, you can use the following formats:
* `suffix:<suffix>` for custom unit that should go after value.
* `prefix:<prefix>` for custom unit that should go before value.
* `time:<format>` For custom date time formats type for example `time:YYYY-MM-DD`.
* `si:<base scale><unit characters>` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character.
* `count:<unit>` for a custom count unit.
* `currency:<unit>` for custom a currency unit.
*/ */
unit?: string; unit?: string;
/** /**
* True if data source can write a value to the path. Auth/authz are supported separately * True if data source can write a value to the path. Auth/authz are supported separately
*/ */
writeable?: boolean; writeable?: boolean;
} }
@ -702,22 +925,37 @@ export const defaultFieldConfig: Partial<FieldConfig> = {
* Row panel * Row panel
*/ */
export interface RowPanel { export interface RowPanel {
/**
* Whether this row should be collapsed or not.
*/
collapsed: boolean; collapsed: boolean;
/** /**
* Name of default datasource. * Name of default datasource for the row
*/
datasource?: DataSourceRef;
/**
* Row grid position
*/ */
datasource?: {
type?: string;
uid?: string;
};
gridPos?: GridPos; gridPos?: GridPos;
/**
* Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
*/
id: number; id: number;
/**
* List of panels in the row
*/
panels: Array<(Panel | GraphPanel | HeatmapPanel)>; panels: Array<(Panel | GraphPanel | HeatmapPanel)>;
/** /**
* Name of template variable to repeat for. * Name of template variable to repeat for.
*/ */
repeat?: string; repeat?: string;
/**
* Row title
*/
title?: string; title?: string;
/**
* The panel type
*/
type: 'row'; type: 'row';
} }
@ -727,7 +965,8 @@ export const defaultRowPanel: Partial<RowPanel> = {
}; };
/** /**
* Support for legacy graph and heatmap panels. * Support for legacy graph panel.
* @deprecated this a deprecated panel type
*/ */
export interface GraphPanel { export interface GraphPanel {
/** /**
@ -741,13 +980,20 @@ export interface GraphPanel {
type: 'graph'; type: 'graph';
} }
/**
* Support for legacy heatmap panel.
* @deprecated this a deprecated panel type
*/
export interface HeatmapPanel { export interface HeatmapPanel {
type: 'heatmap'; type: 'heatmap';
} }
export interface Dashboard { export interface Dashboard {
/** /**
* TODO docs * Contains the list of annotations that are associated with the dashboard.
* Annotations are used to overlay event markers and overlay event tags on graphs.
* Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
* See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
*/ */
annotations?: AnnotationContainer; annotations?: AnnotationContainer;
/** /**
@ -773,7 +1019,7 @@ export interface Dashboard {
graphTooltip: DashboardCursorSync; graphTooltip: DashboardCursorSync;
/** /**
* Unique numeric identifier for the dashboard. * Unique numeric identifier for the dashboard.
* TODO must isolate or remove identifiers local to a Grafana instance...? * `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
*/ */
id?: number; id?: number;
/** /**
@ -782,10 +1028,13 @@ export interface Dashboard {
links?: Array<DashboardLink>; links?: Array<DashboardLink>;
/** /**
* When set to true, the dashboard will redraw panels at an interval matching the pixel width. * When set to true, the dashboard will redraw panels at an interval matching the pixel width.
* This will keep data "moving left" regardless of the query refresh rate. This setting helps * This will keep data "moving left" regardless of the query refresh rate. This setting helps
* avoid dashboards presenting stale live data * avoid dashboards presenting stale live data
*/ */
liveNow?: boolean; liveNow?: boolean;
/**
* List of dashboard panels
*/
panels?: Array<(Panel | RowPanel | GraphPanel | HeatmapPanel)>; panels?: Array<(Panel | RowPanel | GraphPanel | HeatmapPanel)>;
/** /**
* Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". * Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
@ -793,16 +1042,17 @@ export interface Dashboard {
refresh?: (string | false); refresh?: (string | false);
/** /**
* This property should only be used in dashboards defined by plugins. It is a quick check * This property should only be used in dashboards defined by plugins. It is a quick check
* to see if the version has changed since the last time. Unclear why using the version property * to see if the version has changed since the last time.
* is insufficient.
*/ */
revision?: number; revision?: number;
/** /**
* Version of the JSON schema, incremented each time a Grafana update brings * Version of the JSON schema, incremented each time a Grafana update brings
* changes to said schema. * changes to said schema.
* TODO this is the existing schema numbering system. It will be replaced by Thema's themaVersion
*/ */
schemaVersion: number; schemaVersion: number;
/**
* Snapshot options. They are present only if the dashboard is a snapshot.
*/
snapshot?: { snapshot?: {
/** /**
* Time when the snapshot was created * Time when the snapshot was created
@ -851,6 +1101,7 @@ export interface Dashboard {
}; };
/** /**
* Theme of dashboard. * Theme of dashboard.
* Default value: dark.
*/ */
style: ('light' | 'dark'); style: ('light' | 'dark');
/** /**
@ -858,9 +1109,12 @@ export interface Dashboard {
*/ */
tags?: Array<string>; tags?: Array<string>;
/** /**
* Contains the list of configured template variables with their saved values along with some other metadata * Configured template variables
*/ */
templating?: { templating?: {
/**
* List of configured template variables with their saved values along with some other metadata
*/
list?: Array<VariableModel>; list?: Array<VariableModel>;
}; };
/** /**

View File

@ -6,33 +6,30 @@ import { DataQuery } from './common.types';
export type { CommonDataSourceRef as DataSourceRef }; export type { CommonDataSourceRef as DataSourceRef };
export interface Panel<TOptions = Record<string, unknown>, TCustomFieldConfig = Record<string, unknown>> export interface Panel<TOptions = Record<string, unknown>, TCustomFieldConfig = Record<string, unknown>>
extends raw.Panel { extends Omit<raw.Panel, 'fieldConfig'> {
fieldConfig: FieldConfigSource<TCustomFieldConfig>; fieldConfig: FieldConfigSource<TCustomFieldConfig>;
} }
export interface RowPanel extends Omit<raw.RowPanel, 'panels'> {
panels: Array<Panel | raw.GraphPanel | raw.HeatmapPanel>;
}
export enum VariableHide { export enum VariableHide {
dontHide, dontHide,
hideLabel, hideLabel,
hideVariable, hideVariable,
} }
export interface VariableModel export interface VariableModel extends Omit<raw.VariableModel, 'hide' | 'description' | 'datasource'> {
extends Omit<raw.VariableModel, 'rootStateKey' | 'error' | 'description' | 'hide' | 'datasource'> {
// Overrides nullable properties because CUE doesn't support null values
// TODO remove explicit nulls
rootStateKey: string | null;
// TODO remove explicit nulls
error: any | null;
// TODO remove explicit nulls
description: string | null;
hide: VariableHide; hide: VariableHide;
// TODO remove explicit nulls description?: string | null;
datasource: CommonDataSourceRef | null; datasource: DataSourceRef | null;
} }
export interface Dashboard extends Omit<raw.Dashboard, 'templating' | 'annotations'> { export interface Dashboard extends Omit<raw.Dashboard, 'templating' | 'annotations' | 'thresholds' | 'panels'> {
panels?: Array<Panel | raw.RowPanel | raw.GraphPanel | raw.HeatmapPanel>; panels?: Array<Panel | RowPanel | raw.GraphPanel | raw.HeatmapPanel>;
annotations?: AnnotationContainer; annotations?: AnnotationContainer;
thresholds?: ThresholdsConfig;
templating?: { templating?: {
list?: VariableModel[]; list?: VariableModel[];
}; };
@ -48,11 +45,36 @@ export interface AnnotationContainer extends Omit<raw.AnnotationContainer, 'list
list?: AnnotationQuery[]; // use the version from this file list?: AnnotationQuery[]; // use the version from this file
} }
export interface FieldConfig<TOptions = Record<string, unknown>> extends raw.FieldConfig { export interface Threshold extends Omit<raw.Threshold, 'value'> {
custom?: TOptions & Record<string, unknown>; // Value represents a lower bound of a threshold. This triggers a visual change in the dashboard when a graphed value is within the bounds of a threshold.
// Nulls currently appear here when serializing -Infinity to JSON.
value: number | null;
} }
export interface FieldConfigSource<TOptions = Record<string, unknown>> extends raw.FieldConfigSource { export interface ThresholdsConfig extends Omit<raw.ThresholdsConfig, 'steps'> {
steps: Threshold[];
}
export interface FieldConfig<TOptions = Record<string, unknown>> extends Omit<raw.FieldConfig, 'mappings'> {
custom?: TOptions & Record<string, unknown>;
mappings?: ValueMapping[];
}
export type ValueMapping = raw.ValueMap | RangeMap | raw.RegexMap | raw.SpecialValueMap;
export interface RangeMap extends Omit<raw.RangeMap, 'options'> {
// Range to match against and the result to apply when the value is within the range
options: {
// Min value of the range. It can be null which means -Infinity
from: number | null;
// Max value of the range. It can be null which means +Infinity
to: number | null;
// Config to apply when the value is within the range
result: raw.ValueMappingResult;
};
}
export interface FieldConfigSource<TOptions = Record<string, unknown>> extends Omit<raw.FieldConfigSource, 'defaults'> {
defaults: FieldConfig<TOptions>; defaults: FieldConfig<TOptions>;
} }
@ -67,21 +89,16 @@ export interface DataTransformerConfig<TOptions = any> extends raw.DataTransform
export const defaultDashboard = raw.defaultDashboard as Dashboard; export const defaultDashboard = raw.defaultDashboard as Dashboard;
export const defaultVariableModel = { export const defaultVariableModel = {
...raw.defaultVariableModel, ...raw.defaultVariableModel,
// TODO remove explicit nulls
rootStateKey: null,
// TODO remove explicit nulls
error: null,
// TODO remove explicit nulls
description: null, description: null,
hide: VariableHide.dontHide, hide: VariableHide.dontHide,
state: raw.LoadingState.NotStarted,
// TODO remove explicit nulls
datasource: null, datasource: null,
} as VariableModel; } as VariableModel;
export const defaultPanel: Partial<Panel> = raw.defaultPanel; export const defaultPanel: Partial<Panel> = raw.defaultPanel;
export const defaultRowPanel: Partial<Panel> = raw.defaultRowPanel;
export const defaultFieldConfig: Partial<FieldConfig> = raw.defaultFieldConfig; export const defaultFieldConfig: Partial<FieldConfig> = raw.defaultFieldConfig;
export const defaultFieldConfigSource: Partial<FieldConfigSource> = raw.defaultFieldConfigSource; export const defaultFieldConfigSource: Partial<FieldConfigSource> = raw.defaultFieldConfigSource;
export const defaultMatcherConfig: Partial<MatcherConfig> = raw.defaultMatcherConfig; export const defaultMatcherConfig: Partial<MatcherConfig> = raw.defaultMatcherConfig;
export const defaultAnnotationQuery: Partial<AnnotationQuery> = raw.defaultAnnotationQuery as AnnotationQuery; export const defaultAnnotationQuery: Partial<AnnotationQuery> = raw.defaultAnnotationQuery as AnnotationQuery;
export const defaultAnnotationContainer: Partial<AnnotationContainer> = export const defaultAnnotationContainer: Partial<AnnotationContainer> =
raw.defaultAnnotationContainer as AnnotationContainer; raw.defaultAnnotationContainer as AnnotationContainer;
export const defaultThresholdsConfig: Partial<ThresholdsConfig> = raw.defaultThresholdsConfig as ThresholdsConfig;

View File

@ -26,6 +26,25 @@ const (
LinkTypeLink LinkType = "link" LinkTypeLink LinkType = "link"
) )
// Defines values for FieldColorModeId.
const (
FieldColorModeIdContinuousBlPu FieldColorModeId = "continuous-BlPu"
FieldColorModeIdContinuousBlYlRd FieldColorModeId = "continuous-BlYlRd"
FieldColorModeIdContinuousBlues FieldColorModeId = "continuous-blues"
FieldColorModeIdContinuousGrYlRd FieldColorModeId = "continuous-GrYlRd"
FieldColorModeIdContinuousGreens FieldColorModeId = "continuous-greens"
FieldColorModeIdContinuousPurples FieldColorModeId = "continuous-purples"
FieldColorModeIdContinuousRdYlGr FieldColorModeId = "continuous-RdYlGr"
FieldColorModeIdContinuousReds FieldColorModeId = "continuous-reds"
FieldColorModeIdContinuousYlBl FieldColorModeId = "continuous-YlBl"
FieldColorModeIdContinuousYlRd FieldColorModeId = "continuous-YlRd"
FieldColorModeIdFixed FieldColorModeId = "fixed"
FieldColorModeIdPaletteClassic FieldColorModeId = "palette-classic"
FieldColorModeIdPaletteClassicByName FieldColorModeId = "palette-classic-by-name"
FieldColorModeIdShades FieldColorModeId = "shades"
FieldColorModeIdThresholds FieldColorModeId = "thresholds"
)
// Defines values for FieldColorSeriesByMode. // Defines values for FieldColorSeriesByMode.
const ( const (
FieldColorSeriesByModeLast FieldColorSeriesByMode = "last" FieldColorSeriesByModeLast FieldColorSeriesByMode = "last"
@ -43,15 +62,6 @@ const (
HeatmapPanelTypeHeatmap HeatmapPanelType = "heatmap" HeatmapPanelTypeHeatmap HeatmapPanelType = "heatmap"
) )
// Defines values for LoadingState.
const (
LoadingStateDone LoadingState = "Done"
LoadingStateError LoadingState = "Error"
LoadingStateLoading LoadingState = "Loading"
LoadingStateNotStarted LoadingState = "NotStarted"
LoadingStateStreaming LoadingState = "Streaming"
)
// Defines values for MappingType. // Defines values for MappingType.
const ( const (
MappingTypeRange MappingType = "range" MappingTypeRange MappingType = "range"
@ -93,12 +103,6 @@ const (
SpecStyleLight SpecStyle = "light" SpecStyleLight SpecStyle = "light"
) )
// Defines values for SpecialValueMapOptionsMatch.
const (
SpecialValueMapOptionsMatchFalse SpecialValueMapOptionsMatch = "false"
SpecialValueMapOptionsMatchTrue SpecialValueMapOptionsMatch = "true"
)
// Defines values for SpecialValueMapType. // Defines values for SpecialValueMapType.
const ( const (
SpecialValueMapTypeRange SpecialValueMapType = "range" SpecialValueMapTypeRange SpecialValueMapType = "range"
@ -107,6 +111,16 @@ const (
SpecialValueMapTypeValue SpecialValueMapType = "value" SpecialValueMapTypeValue SpecialValueMapType = "value"
) )
// Defines values for SpecialValueMatch.
const (
SpecialValueMatchEmpty SpecialValueMatch = "empty"
SpecialValueMatchFalse SpecialValueMatch = "false"
SpecialValueMatchNan SpecialValueMatch = "nan"
SpecialValueMatchNull SpecialValueMatch = "null"
SpecialValueMatchNullNan SpecialValueMatch = "null+nan"
SpecialValueMatchTrue SpecialValueMatch = "true"
)
// Defines values for ThresholdsMode. // Defines values for ThresholdsMode.
const ( const (
ThresholdsModeAbsolute ThresholdsMode = "absolute" ThresholdsModeAbsolute ThresholdsMode = "absolute"
@ -128,6 +142,13 @@ const (
VariableHideN2 VariableHide = 2 VariableHideN2 VariableHide = 2
) )
// Defines values for VariableRefresh.
const (
VariableRefreshN0 VariableRefresh = 0
VariableRefreshN1 VariableRefresh = 1
VariableRefreshN2 VariableRefresh = 2
)
// Defines values for VariableType. // Defines values for VariableType.
const ( const (
VariableTypeAdhoc VariableType = "adhoc" VariableTypeAdhoc VariableType = "adhoc"
@ -140,8 +161,12 @@ const (
VariableTypeTextbox VariableType = "textbox" VariableTypeTextbox VariableType = "textbox"
) )
// TODO -- should not be a public interface on its own, but required for Veneer // Contains the list of annotations that are associated with the dashboard.
// Annotations are used to overlay event markers and overlay event tags on graphs.
// Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
// See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
type AnnotationContainer struct { type AnnotationContainer struct {
// List of annotations
List []AnnotationQuery `json:"list,omitempty"` List []AnnotationQuery `json:"list,omitempty"`
} }
@ -252,11 +277,16 @@ type DataSourceRef struct {
Uid *string `json:"uid,omitempty"` Uid *string `json:"uid,omitempty"`
} }
// TODO docs // Transformations allow to manipulate data returned by a query before the system applies a visualization.
// Using transformations you can: rename fields, join time series data, perform mathematical operations across queries,
// use the output of one transformation as the input to another transformation, etc.
type DataTransformerConfig struct { type DataTransformerConfig struct {
// Disabled transformations are skipped // Disabled transformations are skipped
Disabled *bool `json:"disabled,omitempty"` Disabled *bool `json:"disabled,omitempty"`
Filter *MatcherConfig `json:"filter,omitempty"`
// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
// It comes with in id ( to resolve implementation from registry) and a configuration thats specific to a particular matcher type.
Filter *MatcherConfig `json:"filter,omitempty"`
// Unique identifier of transformer // Unique identifier of transformer
Id string `json:"id"` Id string `json:"id"`
@ -272,31 +302,73 @@ type DynamicConfigValue struct {
Value *interface{} `json:"value,omitempty"` Value *interface{} `json:"value,omitempty"`
} }
// TODO docs // Map a field to a color.
type FieldColor struct { type FieldColor struct {
// Stores the fixed color value if mode is fixed // The fixed color value for fixed or shades color modes.
FixedColor *string `json:"fixedColor,omitempty"` FixedColor *string `json:"fixedColor,omitempty"`
// The main color scheme mode // Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.
Mode string `json:"mode"` // Continuous color interpolates a color using the percentage of a value relative to min and max.
// Accepted values are:
// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold
// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations
// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations
// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode
// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode
// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode
// `continuous-YlRd`: Continuous Yellow-Red palette mode
// `continuous-BlPu`: Continuous Blue-Purple palette mode
// `continuous-YlBl`: Continuous Yellow-Blue palette mode
// `continuous-blues`: Continuous Blue palette mode
// `continuous-reds`: Continuous Red palette mode
// `continuous-greens`: Continuous Green palette mode
// `continuous-purples`: Continuous Purple palette mode
// `shades`: Shades of a single color. Specify a single color, useful in an override rule.
// `fixed`: Fixed color mode. Specify a single color, useful in an override rule.
Mode FieldColorModeId `json:"mode"`
// TODO docs // Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.
SeriesBy *FieldColorSeriesByMode `json:"seriesBy,omitempty"` SeriesBy *FieldColorSeriesByMode `json:"seriesBy,omitempty"`
} }
// TODO docs // Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.
// Continuous color interpolates a color using the percentage of a value relative to min and max.
// Accepted values are:
// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold
// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations
// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations
// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode
// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode
// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode
// `continuous-YlRd`: Continuous Yellow-Red palette mode
// `continuous-BlPu`: Continuous Blue-Purple palette mode
// `continuous-YlBl`: Continuous Yellow-Blue palette mode
// `continuous-blues`: Continuous Blue palette mode
// `continuous-reds`: Continuous Red palette mode
// `continuous-greens`: Continuous Green palette mode
// `continuous-purples`: Continuous Purple palette mode
// `shades`: Shades of a single color. Specify a single color, useful in an override rule.
// `fixed`: Fixed color mode. Specify a single color, useful in an override rule.
type FieldColorModeId string
// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.
type FieldColorSeriesByMode string type FieldColorSeriesByMode string
// FieldConfig defines model for FieldConfig. // The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
type FieldConfig struct { type FieldConfig struct {
// TODO docs // Map a field to a color.
Color *FieldColor `json:"color,omitempty"` Color *FieldColor `json:"color,omitempty"`
// custom is specified by the FieldConfig field // custom is specified by the FieldConfig field
// in panel plugin schemas. // in panel plugin schemas.
Custom map[string]interface{} `json:"custom,omitempty"` Custom map[string]interface{} `json:"custom,omitempty"`
// Significant digits (for display) // Specify the number of decimals Grafana includes in the rendered value.
// If you leave this field blank, Grafana automatically truncates the number of decimals based on the value.
// For example 1.1234 will display as 1.12 and 100.456 will display as 100.
// To display all decimals, set the unit to `String`.
Decimals *float32 `json:"decimals,omitempty"` Decimals *float32 `json:"decimals,omitempty"`
// Human readable field metadata // Human readable field metadata
@ -317,8 +389,12 @@ type FieldConfig struct {
// Convert input values into a display string // Convert input values into a display string
Mappings []interface{} `json:"mappings,omitempty"` Mappings []interface{} `json:"mappings,omitempty"`
Max *float32 `json:"max,omitempty"`
Min *float32 `json:"min,omitempty"` // The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
Max *float32 `json:"max,omitempty"`
// The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
Min *float32 `json:"min,omitempty"`
// Alternative to empty string // Alternative to empty string
NoValue *string `json:"noValue,omitempty"` NoValue *string `json:"noValue,omitempty"`
@ -328,26 +404,47 @@ type FieldConfig struct {
// //
// When defined, this value can be used as an identifier within the datasource scope, and // When defined, this value can be used as an identifier within the datasource scope, and
// may be used to update the results // may be used to update the results
Path *string `json:"path,omitempty"` Path *string `json:"path,omitempty"`
// Thresholds configuration for the panel
Thresholds *ThresholdsConfig `json:"thresholds,omitempty"` Thresholds *ThresholdsConfig `json:"thresholds,omitempty"`
// Numeric Options // Unit a field should use. The unit you select is applied to all fields except time.
// You can use the units ID availables in Grafana or a custom unit.
// Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts
// As custom unit, you can use the following formats:
// `suffix:<suffix>` for custom unit that should go after value.
// `prefix:<prefix>` for custom unit that should go before value.
// `time:<format>` For custom date time formats type for example `time:YYYY-MM-DD`.
// `si:<base scale><unit characters>` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character.
// `count:<unit>` for a custom count unit.
// `currency:<unit>` for custom a currency unit.
Unit *string `json:"unit,omitempty"` Unit *string `json:"unit,omitempty"`
// True if data source can write a value to the path. Auth/authz are supported separately // True if data source can write a value to the path. Auth/authz are supported separately
Writeable *bool `json:"writeable,omitempty"` Writeable *bool `json:"writeable,omitempty"`
} }
// FieldConfigSource defines model for FieldConfigSource. // The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
type FieldConfigSource struct { type FieldConfigSource struct {
Defaults FieldConfig `json:"defaults"` // The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
Defaults FieldConfig `json:"defaults"`
// Overrides are the options applied to specific fields overriding the defaults.
Overrides []struct { Overrides []struct {
// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
// It comes with in id ( to resolve implementation from registry) and a configuration thats specific to a particular matcher type.
Matcher MatcherConfig `json:"matcher"` Matcher MatcherConfig `json:"matcher"`
Properties []DynamicConfigValue `json:"properties"` Properties []DynamicConfigValue `json:"properties"`
} `json:"overrides"` } `json:"overrides"`
} }
// Support for legacy graph and heatmap panels. // Support for legacy graph panel.
// @deprecated this a deprecated panel type
type GraphPanel struct { type GraphPanel struct {
// @deprecated this is part of deprecated graph panel // @deprecated this is part of deprecated graph panel
Legend *struct { Legend *struct {
@ -361,25 +458,26 @@ type GraphPanel struct {
// GraphPanelType defines model for GraphPanel.Type. // GraphPanelType defines model for GraphPanel.Type.
type GraphPanelType string type GraphPanelType string
// GridPos defines model for GridPos. // Position and dimensions of a panel in the grid
type GridPos struct { type GridPos struct {
// H Panel // Panel height. The height is the number of rows from the top edge of the panel.
H int `json:"h"` H int `json:"h"`
// Whether the panel is fixed within the grid // Whether the panel is fixed within the grid. If true, the panel will not be affected by other panels' interactions
Static *bool `json:"static,omitempty"` Static *bool `json:"static,omitempty"`
// W Panel // Panel width. The width is the number of columns from the left edge of the panel.
W int `json:"w"` W int `json:"w"`
// Panel x // Panel x. The x coordinate is the number of columns from the left edge of the grid
X int `json:"x"` X int `json:"x"`
// Panel y // Panel y. The y coordinate is the number of rows from the top edge of the grid
Y int `json:"y"` Y int `json:"y"`
} }
// HeatmapPanel defines model for HeatmapPanel. // Support for legacy heatmap panel.
// @deprecated this a deprecated panel type
type HeatmapPanel struct { type HeatmapPanel struct {
Type HeatmapPanelType `json:"type"` Type HeatmapPanelType `json:"type"`
} }
@ -387,83 +485,92 @@ type HeatmapPanel struct {
// HeatmapPanelType defines model for HeatmapPanel.Type. // HeatmapPanelType defines model for HeatmapPanel.Type.
type HeatmapPanelType string type HeatmapPanelType string
// LibraryPanelRef defines model for LibraryPanelRef. // A library panel is a reusable panel that you can use in any dashboard.
// When you make a change to a library panel, that change propagates to all instances of where the panel is used.
// Library panels streamline reuse of panels across multiple dashboards.
type LibraryPanelRef struct { type LibraryPanelRef struct {
// Library panel name
Name string `json:"name"` Name string `json:"name"`
Uid string `json:"uid"`
// Library panel uid
Uid string `json:"uid"`
} }
// LoadingState defines model for LoadingState.
type LoadingState string
// Supported value mapping types // Supported value mapping types
// `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
// `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
// `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
// `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A.
type MappingType string type MappingType string
// MatcherConfig defines model for MatcherConfig. // Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
// It comes with in id ( to resolve implementation from registry) and a configuration thats specific to a particular matcher type.
type MatcherConfig struct { type MatcherConfig struct {
Id string `json:"id"` // The matcher id. This is used to find the matcher implementation from registry.
Id string `json:"id"`
// The matcher options. This is specific to the matcher implementation.
Options *interface{} `json:"options,omitempty"` Options *interface{} `json:"options,omitempty"`
} }
// Dashboard panels. Panels are canonically defined inline // Dashboard panels are the basic visualization building blocks.
// because they share a version timeline with the dashboard
// schema; they do not evolve independently.
type Panel struct { type Panel struct {
// The datasource used in all targets. // Ref to a DataSource instance
Datasource *struct { Datasource *DataSourceRef `json:"datasource,omitempty"`
Type *string `json:"type,omitempty"`
Uid *string `json:"uid,omitempty"`
} `json:"datasource,omitempty"`
// Description Description. // Panel description.
Description *string `json:"description,omitempty"` Description *string `json:"description,omitempty"`
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
FieldConfig FieldConfigSource `json:"fieldConfig"` FieldConfig FieldConfigSource `json:"fieldConfig"`
GridPos *GridPos `json:"gridPos,omitempty"`
// TODO docs // Position and dimensions of a panel in the grid
GridPos *GridPos `json:"gridPos,omitempty"`
// Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
Id *int `json:"id,omitempty"` Id *int `json:"id,omitempty"`
// The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables. // The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.
// This value must be formatted as a number followed by a valid time // This value must be formatted as a number followed by a valid time
// identifier like: "40s", "3d", etc. // identifier like: "40s", "3d", etc.
// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options // See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
Interval *string `json:"interval,omitempty"` Interval *string `json:"interval,omitempty"`
// A library panel is a reusable panel that you can use in any dashboard.
// When you make a change to a library panel, that change propagates to all instances of where the panel is used.
// Library panels streamline reuse of panels across multiple dashboards.
LibraryPanel *LibraryPanelRef `json:"libraryPanel,omitempty"` LibraryPanel *LibraryPanelRef `json:"libraryPanel,omitempty"`
// Panel links. // Panel links.
// TODO fill this out - seems there are a couple variants?
Links []Link `json:"links,omitempty"` Links []Link `json:"links,omitempty"`
// The maximum number of data points that the panel queries are retrieving. // The maximum number of data points that the panel queries are retrieving.
MaxDataPoints *float32 `json:"maxDataPoints,omitempty"` MaxDataPoints *float32 `json:"maxDataPoints,omitempty"`
// options is specified by the Options field in panel // It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
// plugin schemas.
Options map[string]interface{} `json:"options"` Options map[string]interface{} `json:"options"`
// FIXME this almost certainly has to be changed in favor of scuemata versions // The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
PluginVersion *string `json:"pluginVersion,omitempty"` PluginVersion *string `json:"pluginVersion,omitempty"`
// Name of template variable to repeat for. // Name of template variable to repeat for.
Repeat *string `json:"repeat,omitempty"` Repeat *string `json:"repeat,omitempty"`
// Direction to repeat in if 'repeat' is set. // Direction to repeat in if 'repeat' is set.
// "h" for horizontal, "v" for vertical. // `h` for horizontal, `v` for vertical.
// TODO this is probably optional RepeatDirection *PanelRepeatDirection `json:"repeatDirection,omitempty"`
RepeatDirection PanelRepeatDirection `json:"repeatDirection"`
// Id of the repeating panel. // Id of the repeating panel.
RepeatPanelId *int64 `json:"repeatPanelId,omitempty"` RepeatPanelId *int64 `json:"repeatPanelId,omitempty"`
// TODO docs // Tags for the panel.
Tags []string `json:"tags,omitempty"` Tags []string `json:"tags,omitempty"`
// TODO docs // Depends on the panel plugin. See the plugin documentation for details.
Targets []Target `json:"targets,omitempty"` Targets []Target `json:"targets,omitempty"`
// TODO docs - seems to be an old field from old dashboard alerts?
Thresholds []interface{} `json:"thresholds,omitempty"`
// Overrides the relative time range for individual panels, // Overrides the relative time range for individual panels,
// which causes them to be different than what is selected in // which causes them to be different than what is selected in
// the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different // the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different
@ -474,9 +581,6 @@ type Panel struct {
// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options // See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
TimeFrom *string `json:"timeFrom,omitempty"` TimeFrom *string `json:"timeFrom,omitempty"`
// TODO docs
TimeRegions []interface{} `json:"timeRegions,omitempty"`
// Overrides the time range for individual panels by shifting its start and end relative to the time picker. // Overrides the time range for individual panels by shifting its start and end relative to the time picker.
// For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`. // For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.
// Note: Panel time overrides have no effect when the dashboards time range is absolute. // Note: Panel time overrides have no effect when the dashboards time range is absolute.
@ -484,30 +588,37 @@ type Panel struct {
TimeShift *string `json:"timeShift,omitempty"` TimeShift *string `json:"timeShift,omitempty"`
// Panel title. // Panel title.
Title *string `json:"title,omitempty"` Title *string `json:"title,omitempty"`
// List of transformations that are applied to the panel data before rendering.
// When there are multiple transformations, Grafana applies them in the order they are listed.
// Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.
Transformations []DataTransformerConfig `json:"transformations"` Transformations []DataTransformerConfig `json:"transformations"`
// Whether to display the panel without a background. // Whether to display the panel without a background.
Transparent bool `json:"transparent"` Transparent bool `json:"transparent"`
// The panel plugin type id. May not be empty. // The panel plugin type id. This is used to find the plugin to display the panel.
Type string `json:"type"` Type string `json:"type"`
} }
// Direction to repeat in if 'repeat' is set. // Direction to repeat in if 'repeat' is set.
// "h" for horizontal, "v" for vertical. // `h` for horizontal, `v` for vertical.
// TODO this is probably optional
type PanelRepeatDirection string type PanelRepeatDirection string
// Maps numeric ranges to a color or different display text // Maps numerical ranges to a display text and color.
// For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
type RangeMap struct { type RangeMap struct {
// Range to match against and the result to apply when the value is within the range
Options struct { Options struct {
// From to and from are `number | null` in current ts, really not sure what to do // Min value of the range. It can be null which means -Infinity
From float64 `json:"from"` From float64 `json:"from"`
// Result used as replacement text and color for RegexMap and SpecialValueMap // Result used as replacement with text and color when the value matches
Result ValueMappingResult `json:"result"` Result ValueMappingResult `json:"result"`
To float64 `json:"to"`
// Max value of the range. It can be null which means +Infinity
To float64 `json:"to"`
} `json:"options"` } `json:"options"`
Type RangeMapType `json:"type"` Type RangeMapType `json:"type"`
} }
@ -515,12 +626,15 @@ type RangeMap struct {
// RangeMapType defines model for RangeMap.Type. // RangeMapType defines model for RangeMap.Type.
type RangeMapType string type RangeMapType string
// Maps regular expressions to replacement text and a color // Maps regular expressions to replacement text and a color.
// For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
type RegexMap struct { type RegexMap struct {
// Regular expression to match against and the result to apply when the value matches the regex
Options struct { Options struct {
// Regular expression to match against
Pattern string `json:"pattern"` Pattern string `json:"pattern"`
// Result used as replacement text and color for RegexMap and SpecialValueMap // Result used as replacement with text and color when the value matches
Result ValueMappingResult `json:"result"` Result ValueMappingResult `json:"result"`
} `json:"options"` } `json:"options"`
Type RegexMapType `json:"type"` Type RegexMapType `json:"type"`
@ -531,24 +645,32 @@ type RegexMapType string
// Row panel // Row panel
type RowPanel struct { type RowPanel struct {
// Whether this row should be collapsed or not.
Collapsed bool `json:"collapsed"` Collapsed bool `json:"collapsed"`
// Name of default datasource. // Ref to a DataSource instance
Datasource *struct { Datasource *DataSourceRef `json:"datasource,omitempty"`
Type *string `json:"type,omitempty"`
Uid *string `json:"uid,omitempty"` // Position and dimensions of a panel in the grid
} `json:"datasource,omitempty"` GridPos *GridPos `json:"gridPos,omitempty"`
GridPos *GridPos `json:"gridPos,omitempty"`
Id int `json:"id"` // Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
Panels []interface{} `json:"panels"` Id int `json:"id"`
// List of panels in the row
Panels []interface{} `json:"panels"`
// Name of template variable to repeat for. // Name of template variable to repeat for.
Repeat *string `json:"repeat,omitempty"` Repeat *string `json:"repeat,omitempty"`
Title *string `json:"title,omitempty"`
Type RowPanelType `json:"type"` // Row title
Title *string `json:"title,omitempty"`
// The panel type
Type RowPanelType `json:"type"`
} }
// RowPanelType defines model for RowPanel.Type. // The panel type
type RowPanelType string type RowPanelType string
// A dashboard snapshot shares an interactive dashboard publicly. // A dashboard snapshot shares an interactive dashboard publicly.
@ -593,7 +715,10 @@ type Snapshot struct {
// Spec defines model for Spec. // Spec defines model for Spec.
type Spec struct { type Spec struct {
// TODO -- should not be a public interface on its own, but required for Veneer // Contains the list of annotations that are associated with the dashboard.
// Annotations are used to overlay event markers and overlay event tags on graphs.
// Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
// See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
Annotations *AnnotationContainer `json:"annotations,omitempty"` Annotations *AnnotationContainer `json:"annotations,omitempty"`
// Description of dashboard. // Description of dashboard.
@ -614,29 +739,29 @@ type Spec struct {
GraphTooltip CursorSync `json:"graphTooltip"` GraphTooltip CursorSync `json:"graphTooltip"`
// Unique numeric identifier for the dashboard. // Unique numeric identifier for the dashboard.
// TODO must isolate or remove identifiers local to a Grafana instance...? // `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
Id *int64 `json:"id,omitempty"` Id *int64 `json:"id,omitempty"`
// Links with references to other dashboards or external websites. // Links with references to other dashboards or external websites.
Links []Link `json:"links,omitempty"` Links []Link `json:"links,omitempty"`
// When set to true, the dashboard will redraw panels at an interval matching the pixel width. // When set to true, the dashboard will redraw panels at an interval matching the pixel width.
// This will keep data "moving left" regardless of the query refresh rate. This setting helps // This will keep data "moving left" regardless of the query refresh rate. This setting helps
// avoid dashboards presenting stale live data // avoid dashboards presenting stale live data
LiveNow *bool `json:"liveNow,omitempty"` LiveNow *bool `json:"liveNow,omitempty"`
Panels []interface{} `json:"panels,omitempty"`
// List of dashboard panels
Panels []interface{} `json:"panels,omitempty"`
// Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". // Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
Refresh *interface{} `json:"refresh,omitempty"` Refresh *interface{} `json:"refresh,omitempty"`
// This property should only be used in dashboards defined by plugins. It is a quick check // This property should only be used in dashboards defined by plugins. It is a quick check
// to see if the version has changed since the last time. Unclear why using the version property // to see if the version has changed since the last time.
// is insufficient.
Revision *int64 `json:"revision,omitempty"` Revision *int64 `json:"revision,omitempty"`
// Version of the JSON schema, incremented each time a Grafana update brings // Version of the JSON schema, incremented each time a Grafana update brings
// changes to said schema. // changes to said schema.
// TODO this is the existing schema numbering system. It will be replaced by Thema's themaVersion
SchemaVersion int `json:"schemaVersion"` SchemaVersion int `json:"schemaVersion"`
// A dashboard snapshot shares an interactive dashboard publicly. // A dashboard snapshot shares an interactive dashboard publicly.
@ -647,13 +772,15 @@ type Spec struct {
Snapshot *Snapshot `json:"snapshot,omitempty"` Snapshot *Snapshot `json:"snapshot,omitempty"`
// Theme of dashboard. // Theme of dashboard.
// Default value: dark.
Style SpecStyle `json:"style"` Style SpecStyle `json:"style"`
// Tags associated with dashboard. // Tags associated with dashboard.
Tags []string `json:"tags,omitempty"` Tags []string `json:"tags,omitempty"`
// Contains the list of configured template variables with their saved values along with some other metadata // Configured template variables
Templating *struct { Templating *struct {
// List of configured template variables with their saved values along with some other metadata
List []VariableModel `json:"list,omitempty"` List []VariableModel `json:"list,omitempty"`
} `json:"templating,omitempty"` } `json:"templating,omitempty"`
@ -699,27 +826,29 @@ type Spec struct {
} }
// Theme of dashboard. // Theme of dashboard.
// Default value: dark.
type SpecStyle string type SpecStyle string
// Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text // Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color.
// and color // See SpecialValueMatch to see the list of special values.
// For example, you can configure a special value mapping so that null values appear as N/A.
type SpecialValueMap struct { type SpecialValueMap struct {
Options struct { Options struct {
Match SpecialValueMapOptionsMatch `json:"match"` // Special value types supported by the `SpecialValueMap`
Pattern string `json:"pattern"` Match SpecialValueMatch `json:"match"`
// Result used as replacement text and color for RegexMap and SpecialValueMap // Result used as replacement with text and color when the value matches
Result ValueMappingResult `json:"result"` Result ValueMappingResult `json:"result"`
} `json:"options"` } `json:"options"`
Type SpecialValueMapType `json:"type"` Type SpecialValueMapType `json:"type"`
} }
// SpecialValueMapOptionsMatch defines model for SpecialValueMap.Options.Match.
type SpecialValueMapOptionsMatch string
// SpecialValueMapType defines model for SpecialValueMap.Type. // SpecialValueMapType defines model for SpecialValueMap.Type.
type SpecialValueMapType string type SpecialValueMapType string
// Special value types supported by the `SpecialValueMap`
type SpecialValueMatch string
// Schema for panel targets is specified by datasource // Schema for panel targets is specified by datasource
// plugins. We use a placeholder definition, which the Go // plugins. We use a placeholder definition, which the Go
// schema loader either left open/as-is with the Base // schema loader either left open/as-is with the Base
@ -735,33 +864,27 @@ type Threshold struct {
// Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded. // Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded.
Color string `json:"color"` Color string `json:"color"`
// Threshold index, an old property that is not needed an should only appear in older dashboards
Index *int32 `json:"index,omitempty"`
// TODO docs
// TODO are the values here enumerable into a disjunction?
// Some seem to be listed in typescript comment
State *string `json:"state,omitempty"`
// Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded. // Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded.
// FIXME the corresponding typescript field is required/non-optional, but nulls currently appear here when serializing -Infinity to JSON // Nulls currently appear here when serializing -Infinity to JSON.
Value *float32 `json:"value,omitempty"` Value float32 `json:"value"`
} }
// ThresholdsConfig defines model for ThresholdsConfig. // Thresholds configuration for the panel
type ThresholdsConfig struct { type ThresholdsConfig struct {
// Thresholds can either be absolute (specific number) or percentage (relative to min or max). // Thresholds can either be `absolute` (specific number) or `percentage` (relative to min or max, it will be values between 0 and 1).
Mode ThresholdsMode `json:"mode"` Mode ThresholdsMode `json:"mode"`
// Must be sorted by 'value', first value is always -Infinity // Must be sorted by 'value', first value is always -Infinity
Steps []Threshold `json:"steps"` Steps []Threshold `json:"steps"`
} }
// Thresholds can either be absolute (specific number) or percentage (relative to min or max). // Thresholds can either be `absolute` (specific number) or `percentage` (relative to min or max, it will be values between 0 and 1).
type ThresholdsMode string type ThresholdsMode string
// Maps text values to a color or different display text // Maps text values to a color or different display text and color.
// For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
type ValueMap struct { type ValueMap struct {
// Map with <value_to_match>: ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } }
Options map[string]ValueMappingResult `json:"options"` Options map[string]ValueMappingResult `json:"options"`
Type ValueMapType `json:"type"` Type ValueMapType `json:"type"`
} }
@ -769,46 +892,107 @@ type ValueMap struct {
// ValueMapType defines model for ValueMap.Type. // ValueMapType defines model for ValueMap.Type.
type ValueMapType string type ValueMapType string
// Result used as replacement text and color for RegexMap and SpecialValueMap // Result used as replacement with text and color when the value matches
type ValueMappingResult struct { type ValueMappingResult struct {
// Text to use when the value matches
Color *string `json:"color,omitempty"` Color *string `json:"color,omitempty"`
Icon *string `json:"icon,omitempty"`
Index *int32 `json:"index,omitempty"` // Icon to display when the value matches. Only specific visualizations.
Text *string `json:"text,omitempty"` Icon *string `json:"icon,omitempty"`
// Position in the mapping array. Only used internally.
Index *int32 `json:"index,omitempty"`
// Text to display when the value matches
Text *string `json:"text,omitempty"`
} }
// VariableHide defines model for VariableHide. // Determine if the variable shows on dashboard
// Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
type VariableHide int type VariableHide int
// FROM: packages/grafana-data/src/types/templateVars.ts // A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
// TODO docs
// TODO what about what's in public/app/features/types.ts?
// TODO there appear to be a lot of different kinds of [template] vars here? if so need a disjunction
type VariableModel struct { type VariableModel struct {
// Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc.
AllFormat *string `json:"allFormat,omitempty"`
// Option to be selected in a variable.
Current *VariableOption `json:"current,omitempty"`
// Ref to a DataSource instance // Ref to a DataSource instance
Datasource *DataSourceRef `json:"datasource,omitempty"` Datasource *DataSourceRef `json:"datasource,omitempty"`
Description *string `json:"description,omitempty"`
Error map[string]interface{} `json:"error,omitempty"`
Global bool `json:"global"`
Hide VariableHide `json:"hide"`
Id string `json:"id"`
Index int `json:"index"`
Label *string `json:"label,omitempty"`
Name string `json:"name"`
// TODO: Move this into a separated QueryVariableModel type // Description of variable. It can be defined but `null`.
Query *interface{} `json:"query,omitempty"` Description *string `json:"description,omitempty"`
RootStateKey *string `json:"rootStateKey,omitempty"`
SkipUrlSync bool `json:"skipUrlSync"`
State LoadingState `json:"state"`
// FROM: packages/grafana-data/src/types/templateVars.ts // Determine if the variable shows on dashboard
// TODO docs // Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
// TODO this implies some wider pattern/discriminated union, probably? Hide VariableHide `json:"hide"`
// Unique numeric identifier for the variable.
Id string `json:"id"`
// Optional display name
Label *string `json:"label,omitempty"`
// Whether multiple values can be selected or not from variable value list
Multi *bool `json:"multi,omitempty"`
// Name of variable
Name string `json:"name"`
// Options that can be selected for a variable.
Options []VariableOption `json:"options,omitempty"`
// Query used to fetch values for a variable
Query *interface{} `json:"query,omitempty"`
// Options to config when to refresh a variable
// `0`: Never refresh the variable
// `1`: Queries the data source every time the dashboard loads.
// `2`: Queries the data source when the dashboard time range changes.
Refresh *VariableRefresh `json:"refresh,omitempty"`
// Whether the variable value should be managed by URL query params or not
SkipUrlSync bool `json:"skipUrlSync"`
// Dashboard variable type
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
// `constant`: Define a hidden constant.
// `datasource`: Quickly change the data source for an entire dashboard.
// `interval`: Interval variables represent time spans.
// `textbox`: Display a free text input field with an optional default value.
// `custom`: Define the variable options manually using a comma-separated list.
// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
Type VariableType `json:"type"` Type VariableType `json:"type"`
} }
// FROM: packages/grafana-data/src/types/templateVars.ts // Option to be selected in a variable.
// TODO docs type VariableOption struct {
// TODO this implies some wider pattern/discriminated union, probably? // Whether the option is selected or not
Selected *bool `json:"selected,omitempty"`
// Text to be displayed for the option
Text interface{} `json:"text"`
// Value of the option
Value interface{} `json:"value"`
}
// Options to config when to refresh a variable
// `0`: Never refresh the variable
// `1`: Queries the data source every time the dashboard loads.
// `2`: Queries the data source when the dashboard time range changes.
type VariableRefresh int
// Dashboard variable type
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
// `constant`: Define a hidden constant.
// `datasource`: Quickly change the data source for an entire dashboard.
// `interval`: Interval variables represent time spans.
// `textbox`: Display a free text input field with an optional default value.
// `custom`: Define the variable options manually using a comma-separated list.
// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
type VariableType string type VariableType string

View File

@ -88,8 +88,8 @@ describe('DashboardModel', () => {
}, },
{ {
type: 'singlestat', type: 'singlestat',
legend: true,
// @ts-expect-error // @ts-expect-error
legend: true,
thresholds: '10,20,30', thresholds: '10,20,30',
colors: ['#FF0000', 'green', 'orange'], colors: ['#FF0000', 'green', 'orange'],
aliasYAxis: { test: 2 }, aliasYAxis: { test: 2 },
@ -665,16 +665,16 @@ describe('DashboardModel', () => {
model = new DashboardModel({ model = new DashboardModel({
templating: { templating: {
list: [ list: [
// @ts-expect-error
{ {
// @ts-expect-error
multi: false, multi: false,
current: { current: {
value: ['value'], value: ['value'],
text: ['text'], text: ['text'],
}, },
}, },
// @ts-expect-error
{ {
// @ts-expect-error
multi: true, multi: true,
current: { current: {
value: ['value'], value: ['value'],
@ -724,8 +724,8 @@ describe('DashboardModel', () => {
}, },
{ {
type: 'query', type: 'query',
// @ts-expect-error
current: { current: {
// @ts-expect-error
tags: [ tags: [
{ {
selected: true, selected: true,
@ -888,52 +888,52 @@ describe('DashboardModel', () => {
model = new DashboardModel({ model = new DashboardModel({
templating: { templating: {
list: [ list: [
// @ts-expect-error
{ {
type: 'query', type: 'query',
hide: VariableHide.dontHide, hide: VariableHide.dontHide,
datasource: null, datasource: null,
// @ts-expect-error
allFormat: '', allFormat: '',
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
hide: VariableHide.hideLabel, hide: VariableHide.hideLabel,
datasource: null, datasource: null,
// @ts-expect-error
allFormat: '', allFormat: '',
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
hide: VariableHide.hideVariable, hide: VariableHide.hideVariable,
datasource: null, datasource: null,
// @ts-expect-error
allFormat: '', allFormat: '',
}, },
// @ts-expect-error
{ {
type: 'constant', type: 'constant',
hide: VariableHide.dontHide, hide: VariableHide.dontHide,
query: 'default value', query: 'default value',
// @ts-expect-error
current: { selected: true, text: 'A', value: 'B' }, current: { selected: true, text: 'A', value: 'B' },
options: [{ selected: true, text: 'A', value: 'B' }], options: [{ selected: true, text: 'A', value: 'B' }],
datasource: null, datasource: null,
allFormat: '', allFormat: '',
}, },
// @ts-expect-error
{ {
type: 'constant', type: 'constant',
hide: VariableHide.hideLabel, hide: VariableHide.hideLabel,
query: 'default value', query: 'default value',
// @ts-expect-error
current: { selected: true, text: 'A', value: 'B' }, current: { selected: true, text: 'A', value: 'B' },
options: [{ selected: true, text: 'A', value: 'B' }], options: [{ selected: true, text: 'A', value: 'B' }],
datasource: null, datasource: null,
allFormat: '', allFormat: '',
}, },
// @ts-expect-error
{ {
type: 'constant', type: 'constant',
hide: VariableHide.hideVariable, hide: VariableHide.hideVariable,
query: 'default value', query: 'default value',
// @ts-expect-error
current: { selected: true, text: 'A', value: 'B' }, current: { selected: true, text: 'A', value: 'B' },
options: [{ selected: true, text: 'A', value: 'B' }], options: [{ selected: true, text: 'A', value: 'B' }],
datasource: null, datasource: null,
@ -995,96 +995,96 @@ describe('DashboardModel', () => {
model = new DashboardModel({ model = new DashboardModel({
templating: { templating: {
list: [ list: [
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_never_refresh_with_options', name: 'variable_with_never_refresh_with_options',
// @ts-expect-error
options: [{ text: 'A', value: 'A' }], options: [{ text: 'A', value: 'A' }],
refresh: 0, refresh: 0,
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_never_refresh_without_options', name: 'variable_with_never_refresh_without_options',
// @ts-expect-error
options: [], options: [],
refresh: 0, refresh: 0,
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_dashboard_refresh_with_options', name: 'variable_with_dashboard_refresh_with_options',
// @ts-expect-error
options: [{ text: 'A', value: 'A' }], options: [{ text: 'A', value: 'A' }],
refresh: 1, refresh: 1,
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_dashboard_refresh_without_options', name: 'variable_with_dashboard_refresh_without_options',
// @ts-expect-error
options: [], options: [],
refresh: 1, refresh: 1,
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_timerange_refresh_with_options', name: 'variable_with_timerange_refresh_with_options',
// @ts-expect-error
options: [{ text: 'A', value: 'A' }], options: [{ text: 'A', value: 'A' }],
refresh: 2, refresh: 2,
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_timerange_refresh_without_options', name: 'variable_with_timerange_refresh_without_options',
// @ts-expect-error
options: [], options: [],
refresh: 2, refresh: 2,
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_no_refresh_with_options', name: 'variable_with_no_refresh_with_options',
// @ts-expect-error
options: [{ text: 'A', value: 'A' }], options: [{ text: 'A', value: 'A' }],
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_no_refresh_without_options', name: 'variable_with_no_refresh_without_options',
// @ts-expect-error
options: [], options: [],
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_unknown_refresh_with_options', name: 'variable_with_unknown_refresh_with_options',
// @ts-expect-error
options: [{ text: 'A', value: 'A' }], options: [{ text: 'A', value: 'A' }],
refresh: 2001, refresh: 2001,
}, },
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'variable_with_unknown_refresh_without_options', name: 'variable_with_unknown_refresh_without_options',
// @ts-expect-error
options: [], options: [],
refresh: 2001, refresh: 2001,
}, },
// @ts-expect-error
{ {
type: 'custom', type: 'custom',
name: 'custom', name: 'custom',
// @ts-expect-error
options: [{ text: 'custom', value: 'custom' }], options: [{ text: 'custom', value: 'custom' }],
}, },
// @ts-expect-error
{ {
type: 'textbox', type: 'textbox',
name: 'textbox', name: 'textbox',
// @ts-expect-error
options: [{ text: 'Hello', value: 'World' }], options: [{ text: 'Hello', value: 'World' }],
}, },
// @ts-expect-error
{ {
type: 'datasource', type: 'datasource',
name: 'datasource', name: 'datasource',
// @ts-expect-error
options: [{ text: 'ds', value: 'ds' }], // fake example doesn't exist options: [{ text: 'ds', value: 'ds' }], // fake example doesn't exist
}, },
// @ts-expect-error
{ {
type: 'interval', type: 'interval',
name: 'interval', name: 'interval',
// @ts-expect-error
options: [{ text: '1m', value: '1m' }], options: [{ text: '1m', value: '1m' }],
}, },
], ],
@ -1334,8 +1334,8 @@ describe('DashboardModel', () => {
panels: [ panels: [
{ {
type: 'singlestat', type: 'singlestat',
legend: true,
// @ts-expect-error // @ts-expect-error
legend: true,
thresholds: '10,20,30', thresholds: '10,20,30',
colors: ['#FF0000', 'green', 'orange'], colors: ['#FF0000', 'green', 'orange'],
aliasYAxis: { test: 2 }, aliasYAxis: { test: 2 },
@ -1396,8 +1396,8 @@ describe('DashboardModel', () => {
panels: [ panels: [
{ {
type: 'singlestat', type: 'singlestat',
legend: true,
// @ts-expect-error // @ts-expect-error
legend: true,
thresholds: '10,20,30', thresholds: '10,20,30',
colors: ['#FF0000', 'green', 'orange'], colors: ['#FF0000', 'green', 'orange'],
aliasYAxis: { test: 2 }, aliasYAxis: { test: 2 },
@ -2004,10 +2004,10 @@ describe('DashboardModel', () => {
model = new DashboardModel({ model = new DashboardModel({
templating: { templating: {
list: [ list: [
// @ts-expect-error
{ {
type: 'query', type: 'query',
name: 'var', name: 'var',
// @ts-expect-error
options: [{ text: 'A', value: 'A' }], options: [{ text: 'A', value: 'A' }],
refresh: 0, refresh: 0,
datasource: null, datasource: null,