Skip to content

VariableModel🔗

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

Definition🔗

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

    # Type of variable
    type_val: dashboard.VariableType
    # Name of variable
    name: str
    # Optional display name
    label: typing.Optional[str]
    # Visibility configuration for the variable
    hide: typing.Optional[dashboard.VariableHide]
    # Whether the variable value should be managed by URL query params or not
    skip_url_sync: typing.Optional[bool]
    # Description of variable. It can be defined but `null`.
    description: typing.Optional[str]
    # Query used to fetch values for a variable
    query: typing.Optional[typing.Union[str, dict[str, object]]]
    # Data source used to fetch values for a variable. It can be defined but `null`.
    datasource: typing.Optional[dashboard.DataSourceRef]
    # Shows current selected variable text/value on the dashboard
    current: typing.Optional[dashboard.VariableOption]
    # Whether multiple values can be selected or not from variable value list
    multi: typing.Optional[bool]
    # Options that can be selected for a variable.
    options: typing.Optional[list[dashboard.VariableOption]]
    # Options to config when to refresh a variable
    refresh: typing.Optional[dashboard.VariableRefresh]
    # Options sort order
    sort: typing.Optional[dashboard.VariableSort]
    # Whether all value option is available or not
    include_all: typing.Optional[bool]
    # Custom all value
    all_value: typing.Optional[str]
    # 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: typing.Optional[str]
    # Dynamically calculates interval by dividing time range by the count specified.
    auto: typing.Optional[bool]
    # The minimum threshold below which the step count intervals will not divide the time.
    auto_min: typing.Optional[str]
    # How many times the current time range should be divided to calculate the value, similar to the Max data points query option.
    # For example, if the current visible time range is 30 minutes, then the auto interval groups the data into 30 one-minute increments.
    auto_count: typing.Optional[int]

Methods🔗

to_json🔗

Converts this object into a representation that can easily be encoded to JSON.

def to_json() -> dict[str, object]

from_json🔗

Builds this object from a JSON-decoded dict.

@classmethod
def from_json(data: dict[str, typing.Any]) -> typing.Self

See also🔗