How to give variables in query metric section of elastic search?

my sample elastic record
{
“_index”: “edge-mumbai-2018.03.25”,
“_type”: “pmdata”,
“_id”: “AWJkkCN8t0Cip9tIBJO2”,
“_score”: 1,
“_source”: {
“SIG_SctpCongestionDuration”: 18,
“SIG_SctpUnavailableDuration”: 8,
“UserLabel”: “BJ01”,
“Time”: “2018-03-25T00:00:00+05:30”,
“NeSerialNo”: “1202000042177AP0003”,
“ObjectType”: “SctpAssoc”,
“Dn”: “CMCC,SubNetwork=1,ManagedElement=1,SctpAssoc=1”,
“Edge”: “edge-mumbai”
}

here i need to plot the graph for feilds SIG_SctpCongestionDuration,SIG_SctpUnavailableDuration with respect to time. In this sample data , fields i am showing only two , but In real time data i may get upto 100 feilds.
I need to use variables instead of giving field names implicitly to show avg of those feilds in same graph. but in grafana elastic query metric , it not taking varibles
image
can anyone please help how to do this?

Hi,

What version of Grafana are you using?

Where you have $variable - if you remove that from input field, do you get autocomple of available field? If so, is the SIG_SctpCongestionDuration listed in drop down for example?

Marcus

Hi,

I have the same issue. If I use the variable in the same situation as reported, it is not working, if I use the field name, it is working.

Looking at the Query inspector, the query with field name looks identical to the query with variable, but the chart is not populated.

Also, how can I use the variable in the alias patterns field. If I put it with var or {{var}} or [[var]] it always shows the string I put in there, not the value of the variable.

Using grafana-5.0.0

I have figured it out.

The problem is, if a variable is used in the field, ElasticSearch query is altered and it renders no result.

If in the “selected field” you put the actual name the query will be: … {“field”:“CPU”}, but if you use $variable, the filter will change to … {“field”:"{CPU}"} and this second query returns null for all values