Use list in Grafana Variables - visualization

I have different Grafana dashboards build on Graphite datasources.
And add variable with such values:
grp1,grp2,grp3,grp4
Now I can choose any group in dropdown menu and it works perfectly
Also I can write in the query body something like:
{grp2,grp4} to get sum of this two groups.
My question - how to make variable value that combine several possible values?
I mean I want to add to dropdown menu more options like some combinations
I tried the same way in Variables menu:
grp1,grp2,grp3,grp4,{grp2,grp4}
but this doesnt works - it create values like {grp2 and grp4}
Also I tried to use Alloption here in the menu, but without success.

You need to escape comma with \, e.g.:
grp1,grp2,grp3,grp4,{grp2\,grp4}
so {grp2,grp4} will be one item in this case.

Related

Autocomplete with multiple values and custom menu for no values

can you help me with Autocomplete component to create a custom menu with text and icon when I don't have any options?
screenshot
I've tried to mix these two examples:
freeSolo with text demo
and
multiple values with freeSolo
Should I use filteredOptions and depend ot in to switch two components in renderOption ?
Basically I have two return statements in the renderOptions, and depends on the user input and matching current options in the Autocomplete I'm trying to switch these components, but without result.
This is my code:
https://codesandbox.io/s/inspiring-mestorf-5f9kty?file=/src/AutocompleteInput.tsx
Any suggestion will be very helpful!

Using regexp with groups in Grafana

I have Grafana dashboards with “Stat” components and I try to change the display names.
I’ve found only one working way: add a field override using regexp. All works, but I can’t use groups in regexp. I want to do something like:
My_own_metric_(.+_.+) -> $1
I’ve tried a lot of different way to write it: $1, \1, ${“\1”},..
But I was only able to change it on static text.
I’m using Grafana-8.3.3-Ubuntu version.
Maybe someone knows a solution?
Apparently it's not possible to use groups in field override.
What you need to do is add an "operation" in the query itself:
+ Operations > Functions > Label replace
and set the legend:
Options > Legend > Custom > {{yourlabel}}.
So, an example for a straightforward mqtt exporter query,
changing the displayed label
from $SYS/broker/clients/maximum
to maximum:

Group AEM (6.2) component configurations

I'm currently building a component that has TouchUI configuration properties separated with three tabs (Standard, CASL, GDPR). Each tab has the same set of options available and my current config names are similar to the following:
./standardMarketingText
./standardThirdpartyText
./gdprMarketingText
./gdprThirdpartyText
./caslMarketingText
./caslThirdpartyText
(There are several other options for standard,gdpr,casl but I left them out for brevity)
While this works, I'm hoping to instead store the values in the JCR as a JSON node per category. For example:
casl = {"marketingText"="m test", "thirdpartyText"="tp test"}
gdpr = {"marketingText"="gdpr m test", "thirdpartyText"="gdpr tp test"}
This way I can load all "casl" (or others) options at once when I need them (there isn't a case where I would only load one "casl" option)
I have attempted using granite/ui/components/foundation/form/multifield however, it asks to "Add field". I only want one set of each, and not provide the ability to add another set of properties under each tab. Is there a way to accomplish this without overriding the multifield resourceType?
There are multiple ways to achieve what you are looking at, I would look at the reusability as there are similar named properties for different categories (in your case tabs). To group them you could do that at node level by correctly defining the name property for each tab.
For above provided values, you could do something like -
./standard/marketingText
./standard/thirdpartyText
./gdpr/marketingText
./gdpr/thirdpartyText
./casl/marketingText
./casl/thirdpartyText
Your each tab stores the properties in named node (standard, gdpr, casl). In addition you could have a single SlingModel/WCMUsePojo that can adapt to these nodes to provide the Pojo with accessor to property values.
As far as getting JSON is concerned, your SlingModel or WCMUsePojo can provide a method to return JSON based string for the values.

How to access variable, passed through URL in grafana?

I am trying to make a detailed dashboard in grafana that opens on click. I do it by passing a variable to the dashboard debending on the clicked facility. When the dashboard opens it needs to display value using the passed url variable inst. I just cannot seem to get it working. Here is an example of my dashboard link.
How can i use the variable inst?
I will add gogibogi4's correct answer. The Grafana documentation is lacking on this.
In your drill-down dashboard, add a constant variable. To be retrieved in Grafana, you need the prefix var- then the name of the variable in the query string. Let's assume the variable is "region." The URL coming into the drilldown dashboard should look similar to the following:
/drilldowndashboard/?var-region=NorthWest
Drilldown Dashboard Settings:
In the drilldown dashboard settings, create a variable. The Name in this example is "region" Make the type Constant. Under Hide, you can just leave that unselected. Under Constant options, you can write the word "blank" The preview of values will just show the word "blank" but go ahead and save it as it will be replaced in the query.
Query:
You can refer to the variable using [[region]] in your data query.
Parent Dashboard:
The parent dashboard merely needs to refer to the drilldown dashboard with var-region as a query parameter.
I figured out the solution on my own. The variable that i wanted to pass was var-inst, the trick to use it is to create a custom template variable named inst and give it a dummy value. After that is done i can use the passed value by using $inst. Note that in order for the variable to be passed i had to go back to my primary dashboard and then i had to click my link again. After that the value got passed and is working perfectly.
just referred above answer by gogibogi4 and it worked for me but when I tried to see variable information then I saw I have selected constant as a type but automatically it got converted into datasource and type is selected grafana. when I try to select them manually it didn't worked. this is some kind of bug of grafana I guess.

How to make dynamic drop down lists on parameterized build page in a custom Hudson plugin?

I am trying to achieve the following for a parameterized hudson job: when a user clicks on 'build now' he should be presented with three drop down list parameters viz., Environment, Server, Port. I want the drop down to be dynamic i.e on changing the value of environment the list of servers should change accordingly and similarly the values of port should change on the basis of selected server.
Once a user makes the final selection, all three values from the dropdowns are to be used to make a single value to be passed to the build job as a parameter. I am stuck at how to achieve this in a single parameter and make it dynamic. In my custom plugin i have extended the ParameterDefinition class and within it i have a static nested class extending the ParameterDescriptor class with doFillXXXItems() for these three fields. The values in environment dropdown are populated on the basis of logged in username. I would really appreciate it if somebody could help me figure out how to make the drop downs dynamic. I have already tried the dynamic drop down listbox in ui-samples plugin but its not working in my case :(
You could inherit hudson.model.ChoiceParameterDefinition, and override its method of getChoicesText. return the options based on whatever you want, in your situation, you could get environments from Hudson.getInstance().
Below snippets is shown how get environment variable.
Hudson.getInstance().getGlobalNodeProperties()
.get(EnvironmentVariablesNodeProperty.class).getEnvVars().get(name);