Add support for free text variables to be defined in metrics dashboard yaml files
Problem to solve
We need to be able to define variables in our dashboards. This feature is similar to variables in Grafana.
Intended users
Further details
In this issue, we will allow simple text
variables where the user can set any value for the variable.
Proposal
The following should be added to a dashboard in order for the dashboard to have template variables. The variables can be used in queries.
Note that the templating
key will be a top-level dashboard property.
Simple syntax
This is a simple syntax that reduces the amount of configuration that needs to be added to the yaml, and should hopefully be enough for most use-cases.
templating:
variables:
variable1: 'default value' # `text` type variable with `default value` as its default.
This will create a variable called variable1
, whose value can be any string. The default value will be default value
. The UI will have a free text box for this variable.
Advanced syntax
templating:
variables:
variable1: # The name that can be used in queries in the form `%{variable1}`.
label: 'Variable 1' # (Optional) label that will appear in the UI for this dropdown.
type: text
options:
default_value: 'default' # (Optional) default value.
If the label
key is not present, the name of the variable can be used as label. If the default_value
key is not present, the default value of the variable can be blank.
Permissions and Security
Documentation
This needs to be documented at https://docs.gitlab.com/ee/user/project/integrations/prometheus.html#dashboard-yaml-properties with a warning that this is an alpha feature.
Availability & Testing
What does success look like, and how can we measure that?
When the above is added to a dashboard yaml file, the resulting dashboard UI has a free text box for each text
type of variable. When a user changes the text in the box and presses enter, the dashboard should reload with the given value being passed to all Prometheus Proxy API requests.
Links / references
Spike to decide syntax: #201758 (closed)