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

Populating and setting a variable's current value #165

Open
jstaffans-relex opened this issue Feb 6, 2024 · 3 comments
Open

Populating and setting a variable's current value #165

jstaffans-relex opened this issue Feb 6, 2024 · 3 comments
Labels
question Further information is requested

Comments

@jstaffans-relex
Copy link

jstaffans-relex commented Feb 6, 2024

Hi and thanks for the work on making grafonnet better aligned with the development of Grafana!

I have been playing around with the 10.2.0 API and Grafana 10.2.3 and now have the following variable definition:

{ 
  abc:
    var.custom.new('abc', values=['true', 'false', 'limited'])
    + var.custom.generalOptions.withLabel('Abc?')
    + var.custom.generalOptions.withCurrent('false')
    + var.custom.selectionOptions.withMulti(false)
    + var.custom.selectionOptions.withIncludeAll()
}

However, the variable's current value remains "true" despite the withCurrent('false'). How do I influence the variable's current (default) value?

Also, how do I make the default value "All"?

And finally, query type variables do not seem to populate as expected. After uploading a dashboard definition including the use of query variables, I need to manually go and click Run query in the Grafana variable editor UI to populate values.

@jstaffans-relex jstaffans-relex changed the title Setting a variable's current value Populating and setting a variable's current value Feb 6, 2024
@Duologic
Copy link
Member

Duologic commented Feb 13, 2024

Here is the output I see when executing that, can you say what you are referring to specifically?

{
   "abc": {
      "current": {
         "selected": false,
         "text": [
            "false"
         ],
         "value": [
            "false"
         ]
      },
      "includeAll": true,
      "label": "Abc?",
      "multi": false,
      "name": "abc",
      "options": [
         {
            "selected": true,
            "text": "true",
            "value": "true"
         },
         {
            "selected": false,
            "text": "false",
            "value": "false"
         },
         {
            "selected": false,
            "text": "limited",
            "value": "limited"
         }
      ],
      "query": "true : true,false : false,limited : limited",
      "type": "custom"
   }
}

Have you run this in Grafana and was that not working as expected, how did it behave?

@Duologic
Copy link
Member

Duologic commented Feb 13, 2024

Also, how do I make the default value "All"?

It looks like that has changed since the inception of the code that supports this. I've made an issue for this: #166

@Duologic
Copy link
Member

And finally, query type variables do not seem to populate as expected. After uploading a dashboard definition including the use of query variables, I need to manually go and click Run query in the Grafana variable editor UI to populate values.

Can you create a separate issue with examples? We've tried to cover for this in the past so examples might help identify what's causing this.

@Duologic Duologic added the question Further information is requested label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants