hawkular / hawkular-grafana-datasource

Hawkular Datasource for Grafana
Apache License 2.0
22 stars 35 forks source link

Tags query not removing single quote from template variable #102

Open viv816 opened 6 years ago

viv816 commented 6 years ago

Hi,

Grafana Version= 4.1.2 Hawkular Version = 0.28.1.Final

I want to use variable value in tags QL as follows

Actual Query :

labels.app=$app AND metric_name='org.apache.camel:context=[[app]],name=*,type=routes#MaxProcessingTime'

Expected Result :

labels.app='demo-context' AND metric_name='org.apache.camel:context=demo-context,name=*,type=routes#MaxProcessingTime'

I want [[app]] to be replaced by demo-context instead of 'demo-context'. How do I do it?

The tags QL currently throws an error if it encounters single quote

jotak commented 6 years ago

Can you try by turning off the tags edit mode? As described here: https://github.com/hawkular/hawkular-grafana-datasource#queries (third image)

viv816 commented 6 years ago

Thanks for responding.

I still get error after turning off the tags edit mode. When I check the value for [[app]] after clicking the red icon on top left, the value is still enclosed in single quotes.

I want this as output

metric_name='org.apache.camel:context=ws-cifdetail,name=*,type=routes#Load01'

not this

metric_name='org.apache.camel:context='ws-cifdetail',name=*,type=routes#Load01'

Appreciate your help.

Thanks in advance.

Attaching the screen shots below.

error

error2

jotak commented 6 years ago

Hi @viv816 , I'm trying to find the best way to solve this issue. The variable content is escaped in order to prevent failures in the tags parser, in constructs such as: my_tag IN [$app] , where a character like , or ] in $app would break the parsing.

A workaround could be to define a new "custom" variable in Grafana with nested $app, like this: metric_name='org.apache.camel:context=$app,name=*,type=routes#Load01' but unfortunately it doesn't seem to work for me, maybe you would have better luck? (nested variables are supposed to be supported in Grafana, but maybe it's only for variables of type "query", i'm not sure...)

viv816 commented 6 years ago

Hi @jotak ,

Thanks.

Is there any other way to solve this issue? Where can I find more help for this problem?

jotak commented 6 years ago

Sorry for the late response, I have been quite busy these weeks. I've just proposed a solution here: https://github.com/hawkular/hawkular-grafana-datasource/pull/103

viv816 commented 6 years ago

Thank you very much.

I will try to pull the new image and inform you after my testing.

apolegoshko commented 5 years ago

+1 to this