Skip to content

VariableModel🔗

A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.

Definition🔗

type VariableModel struct {
    // Type of variable
    Type dashboard.VariableType `json:"type"`
    // Name of variable
    Name string `json:"name"`
    // Optional display name
    Label *string `json:"label,omitempty"`
    // Visibility configuration for the variable
    Hide *dashboard.VariableHide `json:"hide,omitempty"`
    // Whether the variable value should be managed by URL query params or not
    SkipUrlSync *bool `json:"skipUrlSync,omitempty"`
    // Description of variable. It can be defined but `null`.
    Description *string `json:"description,omitempty"`
    // Query used to fetch values for a variable
    Query *dashboard.StringOrMap `json:"query,omitempty"`
    // Data source used to fetch values for a variable. It can be defined but `null`.
    Datasource *dashboard.DataSourceRef `json:"datasource,omitempty"`
    // Shows current selected variable text/value on the dashboard
    Current *dashboard.VariableOption `json:"current,omitempty"`
    // Whether multiple values can be selected or not from variable value list
    Multi *bool `json:"multi,omitempty"`
    // Options that can be selected for a variable.
    Options []dashboard.VariableOption `json:"options,omitempty"`
    // Options to config when to refresh a variable
    Refresh *dashboard.VariableRefresh `json:"refresh,omitempty"`
    // Options sort order
    Sort *dashboard.VariableSort `json:"sort,omitempty"`
    // Whether all value option is available or not
    IncludeAll *bool `json:"includeAll,omitempty"`
    // Custom all value
    AllValue *string `json:"allValue,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"`
}

Methods🔗

UnmarshalJSONStrict🔗

UnmarshalJSONStrict implements a custom JSON unmarshalling logic to decode VariableModel from JSON.

Note: the unmarshalling done by this function is strict. It will fail over required fields being absent from the input, fields having an incorrect type, unexpected fields being present, …

func (variableModel *VariableModel) UnmarshalJSONStrict(raw []byte) error

Equals🔗

Equals tests the equality of two VariableModel objects.

func (variableModel *VariableModel) Equals(other VariableModel) bool

Validate🔗

Validate checks all the validation constraints that may be defined on VariableModel fields for violations and returns them.

func (variableModel *VariableModel) Validate() error

See also🔗