mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DashboardSchema: Add options to VariableModel (#79236)
* Add includeAll and regex fields to VariableModel #67639 * Add allValue option to VariableModel
This commit is contained in:
parent
cbdbdf72e5
commit
f7fd8e6cd1
@ -606,15 +606,18 @@ A variable is a placeholder for a value. You can use variables in metric queries
|
|||||||
|---------------|-------------------------------------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|---------------|-------------------------------------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `name` | string | **Yes** | | Name of variable |
|
| `name` | string | **Yes** | | Name of variable |
|
||||||
| `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`. |
|
| `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`. |
|
||||||
|
| `allValue` | string | No | | Custom all value |
|
||||||
| `current` | [VariableOption](#variableoption) | No | | Option to be selected in a variable. |
|
| `current` | [VariableOption](#variableoption) | No | | Option to be selected in a variable. |
|
||||||
| `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 | | Description of variable. It can be defined but `null`. |
|
||||||
| `hide` | integer | No | | 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 | No | | 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`. |
|
||||||
|
| `includeAll` | boolean | No | `false` | Whether all value option is available or not |
|
||||||
| `label` | string | No | | Optional display name |
|
| `label` | string | No | | Optional display name |
|
||||||
| `multi` | boolean | No | `false` | Whether multiple values can be selected or not from variable value list |
|
| `multi` | boolean | No | `false` | Whether multiple values can be selected or not from variable value list |
|
||||||
| `options` | [VariableOption](#variableoption)[] | No | | Options that can be selected for a variable. |
|
| `options` | [VariableOption](#variableoption)[] | No | | Options that can be selected for a variable. |
|
||||||
| `query` | | No | | Query used to fetch values for a variable |
|
| `query` | | No | | Query used to fetch values for a variable |
|
||||||
| `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`. |
|
| `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`. |
|
||||||
|
| `regex` | string | No | | Optional field, if you want to extract part of a series name or metric node segment.<br/>Named capture groups can be used to separate the display text and value. |
|
||||||
| `skipUrlSync` | boolean | No | `false` | Whether the variable value should be managed by URL query params or not |
|
| `skipUrlSync` | boolean | No | `false` | Whether the variable value should be managed by URL query params or not |
|
||||||
| `sort` | integer | No | | Sort variable options<br/>Accepted values are:<br/>`0`: No sorting<br/>`1`: Alphabetical ASC<br/>`2`: Alphabetical DESC<br/>`3`: Numerical ASC<br/>`4`: Numerical DESC<br/>`5`: Alphabetical Case Insensitive ASC<br/>`6`: Alphabetical Case Insensitive DESC<br/>`7`: Natural ASC<br/>`8`: Natural DESC<br/>Possible values are: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`. |
|
| `sort` | integer | No | | Sort variable options<br/>Accepted values are:<br/>`0`: No sorting<br/>`1`: Alphabetical ASC<br/>`2`: Alphabetical DESC<br/>`3`: Numerical ASC<br/>`4`: Numerical DESC<br/>`5`: Alphabetical Case Insensitive ASC<br/>`6`: Alphabetical Case Insensitive DESC<br/>`7`: Natural ASC<br/>`8`: Natural DESC<br/>Possible values are: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`. |
|
||||||
|
|
||||||
|
@ -199,9 +199,17 @@ lineage: schemas: [{
|
|||||||
multi?: bool | *false
|
multi?: bool | *false
|
||||||
// Options that can be selected for a variable.
|
// Options that can be selected for a variable.
|
||||||
options?: [...#VariableOption]
|
options?: [...#VariableOption]
|
||||||
|
// Options to config when to refresh a variable
|
||||||
refresh?: #VariableRefresh
|
refresh?: #VariableRefresh
|
||||||
// Options sort order
|
// Options sort order
|
||||||
sort?: #VariableSort
|
sort?: #VariableSort
|
||||||
|
// Whether all value option is available or not
|
||||||
|
includeAll?: bool | *false
|
||||||
|
// Custom all value
|
||||||
|
allValue?: string
|
||||||
|
// Optional field, if you want to extract part of a series name or metric node segment.
|
||||||
|
// Named capture groups can be used to separate the display text and value.
|
||||||
|
regex?: string
|
||||||
...
|
...
|
||||||
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
|
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
|
||||||
|
|
||||||
|
@ -126,6 +126,10 @@ export const defaultAnnotationQuery: Partial<AnnotationQuery> = {
|
|||||||
* A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
* A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
||||||
*/
|
*/
|
||||||
export interface VariableModel {
|
export interface VariableModel {
|
||||||
|
/**
|
||||||
|
* Custom all value
|
||||||
|
*/
|
||||||
|
allValue?: string;
|
||||||
/**
|
/**
|
||||||
* Shows current selected variable text/value on the dashboard
|
* Shows current selected variable text/value on the dashboard
|
||||||
*/
|
*/
|
||||||
@ -142,6 +146,10 @@ export interface VariableModel {
|
|||||||
* Visibility configuration for the variable
|
* Visibility configuration for the variable
|
||||||
*/
|
*/
|
||||||
hide?: VariableHide;
|
hide?: VariableHide;
|
||||||
|
/**
|
||||||
|
* Whether all value option is available or not
|
||||||
|
*/
|
||||||
|
includeAll?: boolean;
|
||||||
/**
|
/**
|
||||||
* Optional display name
|
* Optional display name
|
||||||
*/
|
*/
|
||||||
@ -162,7 +170,15 @@ export interface VariableModel {
|
|||||||
* Query used to fetch values for a variable
|
* Query used to fetch values for a variable
|
||||||
*/
|
*/
|
||||||
query?: (string | Record<string, unknown>);
|
query?: (string | Record<string, unknown>);
|
||||||
|
/**
|
||||||
|
* Options to config when to refresh a variable
|
||||||
|
*/
|
||||||
refresh?: VariableRefresh;
|
refresh?: VariableRefresh;
|
||||||
|
/**
|
||||||
|
* Optional field, if you want to extract part of a series name or metric node segment.
|
||||||
|
* Named capture groups can be used to separate the display text and value.
|
||||||
|
*/
|
||||||
|
regex?: string;
|
||||||
/**
|
/**
|
||||||
* Whether the variable value should be managed by URL query params or not
|
* Whether the variable value should be managed by URL query params or not
|
||||||
*/
|
*/
|
||||||
@ -178,6 +194,7 @@ export interface VariableModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const defaultVariableModel: Partial<VariableModel> = {
|
export const defaultVariableModel: Partial<VariableModel> = {
|
||||||
|
includeAll: false,
|
||||||
multi: false,
|
multi: false,
|
||||||
options: [],
|
options: [],
|
||||||
skipUrlSync: false,
|
skipUrlSync: false,
|
||||||
|
@ -900,6 +900,9 @@ type VariableHide int
|
|||||||
|
|
||||||
// A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
// A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
||||||
type VariableModel struct {
|
type VariableModel struct {
|
||||||
|
// Custom all value
|
||||||
|
AllValue *string `json:"allValue,omitempty"`
|
||||||
|
|
||||||
// Option to be selected in a variable.
|
// Option to be selected in a variable.
|
||||||
Current *VariableOption `json:"current,omitempty"`
|
Current *VariableOption `json:"current,omitempty"`
|
||||||
|
|
||||||
@ -913,6 +916,9 @@ type VariableModel struct {
|
|||||||
// Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
|
// Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
|
||||||
Hide *VariableHide `json:"hide,omitempty"`
|
Hide *VariableHide `json:"hide,omitempty"`
|
||||||
|
|
||||||
|
// Whether all value option is available or not
|
||||||
|
IncludeAll *bool `json:"includeAll,omitempty"`
|
||||||
|
|
||||||
// Optional display name
|
// Optional display name
|
||||||
Label *string `json:"label,omitempty"`
|
Label *string `json:"label,omitempty"`
|
||||||
|
|
||||||
@ -934,6 +940,10 @@ type VariableModel struct {
|
|||||||
// `2`: Queries the data source when the dashboard time range changes.
|
// `2`: Queries the data source when the dashboard time range changes.
|
||||||
Refresh *VariableRefresh `json:"refresh,omitempty"`
|
Refresh *VariableRefresh `json:"refresh,omitempty"`
|
||||||
|
|
||||||
|
// Optional field, if you want to extract part of a series name or metric node segment.
|
||||||
|
// Named capture groups can be used to separate the display text and value.
|
||||||
|
Regex *string `json:"regex,omitempty"`
|
||||||
|
|
||||||
// Whether the variable value should be managed by URL query params or not
|
// Whether the variable value should be managed by URL query params or not
|
||||||
SkipUrlSync *bool `json:"skipUrlSync,omitempty"`
|
SkipUrlSync *bool `json:"skipUrlSync,omitempty"`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user