Skip to content
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

Dashboard variables: set default value on import #3384

Closed
mamoep opened this issue Dec 16, 2024 · 5 comments · Fixed by #3399
Closed

Dashboard variables: set default value on import #3384

mamoep opened this issue Dec 16, 2024 · 5 comments · Fixed by #3399
Assignees

Comments

@mamoep
Copy link

mamoep commented Dec 16, 2024

Is your feature request related to a problem? Please describe.
I have three datacenters (labeled A,B,C) and most of the time I want to look at clusters in datacenter B. After dashboard import every dashboard uses A as default chosen datacenter.

Describe the solution you'd like
I want to chose the default value of the datacenter variable when using bin/harvest grafana import

Describe alternatives you've considered
It is possible to change and save the dashboard after import, but it is tedious task.

Additional context
n/a

@mamoep mamoep added the feature New feature or request label Dec 16, 2024
@rahulguptajss rahulguptajss self-assigned this Dec 16, 2024
@rahulguptajss
Copy link
Contributor

@mamoep Check if the following DSL in the import command meets your request:

Use the --var-defaults flag to specify default values nfor dropdown variables in grafana. The format is:

variable1=value1,value2;variable2=value3
  • variable1, variable2, ...: Names of the dropdown variables.
  • value1, value2, ...: Default values for each variable (comma-separated).
  • ; Separate different variables with a semicolon.

Example

bin/grafana import --var-defaults "Datacenter=DC1,DC2;Cluster=Cluster1"

This sets:

  • Datacenter dropdown to default to DC1 and DC2.
  • Cluster dropdown to default to Cluster1.

@mamoep
Copy link
Author

mamoep commented Dec 18, 2024

That proposal looks good to me.

@mamoep
Copy link
Author

mamoep commented Dec 20, 2024

I really appreciate that you picked this feature request so fast. Don't forget to add some documention. ;)

@rahulguptajss
Copy link
Contributor

I really appreciate that you picked this feature request so fast. Don't forget to add some documention. ;)

You're welcome. I have initiated a nightly build for you to try. I'll update you once it is available. Yes, the documentation has been added to the CLI. It will look like this:

--var-defaults string     
                          Default values for dropdown variables in the format 'variable1=value1,value2;variable2=value3'.
                          
                          Examples:
                          
                          1. Set a single variable:
                             To set the default value for the 'Datacenter' variable to 'DC1':
                             --var-defaults "Datacenter=DC1"
                          
                          2. Set multiple values for a single variable:
                             To set the default values for the 'Datacenter' variable to 'DC1' and 'DC2':
                             --var-defaults "Datacenter=DC1,DC2"
                          
                          3. Set multiple variables in one command:
                             To set the default values for 'Datacenter' to 'DC1' and 'DC2', and 'Cluster' to 'Cluster1':
                             --var-defaults "Datacenter=DC1,DC2;Cluster=Cluster1"
                          
                          4. Set multiple values for multiple variables:
                             To set the default values for 'Datacenter' to 'DC1' and 'DC2', and 'Cluster' to 'Cluster1' and 'Cluster2':
                             --var-defaults "Datacenter=DC1,DC2;Cluster=Cluster1,Cluster2"
                          
                          Note: Ensure that variable names and values do not contain the characters '=', ',', or ';' as these are used as delimiters.

@rahulguptajss
Copy link
Contributor

You can try these changes in nightly build and provide feedback. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants