-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dashboards: Data source template variable options now specify a current value using uid. #69259
Dashboards: Data source template variable options now specify a current value using uid. #69259
Conversation
value
field)
@darrenjaneczek I see the point of this change, and I do think this is a good direction. Tho, I'm afraid this is a breaking change from the POV of the variable interpolation. Given a data source variable (
is interpolated as:
After your changes, it's interpolated as:
Think this should be ok, but requires a breaking change notice and an update for everyone who's relying in their dashboards on the data source name being returned by I'm ok accepting this change but would like to hear thoughts from @axelavargas and @torkelo before proceeding with it. |
I think this change makes sense as well, it could be a breaking change for some edge cases where data source variable is not used for it's normal use cases (as value in the datasource / datasource.uid prop). So we need to add a breaking change release notes notice (add breaking change label to this PR, and a section in the PR description with title "Release notice breaking change" , see #66466 for example. |
@darrenjaneczek one more comment. I see the milestone you set is 9.5.x. Given this is a breaking change I think we need to release it in 10.1. |
@dprokop |
Yes, it is, the hard freeze for G10 started last week 😓 I like this change, it goes in the right direction. I'd love to have second eyes on this one, but it looks good. About breaking change notes, it creates the necessity for the customer to do something about this change, but it is not clear what use cases are affected by this change.
|
Sad that I missed the G10 boat 🚢.
|
Please see this PR for the breaking change to raw. #69259
* Update index.md Please see this PR for the breaking change to raw. #69259 * Update docs/sources/dashboards/variables/variable-syntax/index.md Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> * Fixed linting error --------- Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
What is this feature?
The goal was to make it possible for a dashboard to specify a provisioned data source as the "current" option for a template variable. The only way to currently achieve this is to use the name of the datasource, but for our use case this would vary between grafana cloud instances.
The solution makes use of the
value
part of the{text, value}
structure under a template variable'soptions.current
. Thevalue
field was being completely ignored and was a duplicate oftext
: the name of data source. This PR now takes thevalue
into consideration when resolving the initial template variable value, and for data source template variables, thevalue
now corresponds to the uid. It will be reflected in new dashboard JSON accordingly. Old dashboard JSON which uses the data source name will still function as before.Why do we need this feature?
When provisioning dashboards and datasources with specific uids, we might want a dashboard to initially select that specific datasource first, instead of defaulting to alphabetical order and choosing the first on the list. This should also make it possible to set a selected value for query-based template variables as well.
Who is this feature for?
Specifically, cloud customers accessing the Cardinality management dashboards with multiple metrics datasources defined. We want the dashboards to choose the provisioned
grafanacloud-prom
to be selected first by default when opening the dashboard, instead of the datasource with the earliest name in alphabetical sort. Since thegrafanacloud-prom
datasource has a inconstant name:grafanacloud-${instanceName}-prom
, it cannot be specified by setting thecurrent
value in dashboard JSON. This PR allows specifying that uid through the variable'scurrent.value
field.Special notes for your reviewer:
current
fields oftext
, andvalue
would both be set to the data source name. Nowtext
gets the name, andvalue
gets the uid. This will be reflected in the JSON. Old dashboards which use the name for both will still be compatible.Please check that:
Release notice breaking change
The data source template variable type has changed the way it represents its options. The
text
field still represents the data source name, but thevalue
has been changed to theuid
of the data source. This allows dashboards to declare the currently selected option byuid
, however it changes how a datasource template variable value will be rendered by default. If the name of the data source is expected, the variable syntax will have to be changed to specify the text format.For example, given a data source variable (datasourceVariable), the following string:
was previously interpolated as:
After these changes, it's interpolated as:
Any dashboards that are relying on the data source name being returned by
${datasourceVariable}
will have to update all their usages to${datasourceVariable:text}
in order to get the previous behavior.Affected use cases:
${datasourceVariable}
to display the data source name in text panel or in the panel title.${datasourceVariable}
to use the data source name as part of the query content.Unaffected use cases:
${datasourceVariable}
to choose which data source to use for a query (through its data source picker) will not be affected since it can use both the name and the uid