gbrian / grafana-timelion-datasource

ELK Timelion's data source for Grafana
MIT License
15 stars 12 forks source link

Fixing multiple parameters to use Lucene format #18

Open mateczagany opened 5 years ago

mateczagany commented 5 years ago

Hi Brian,

We had problems with substituting Grafana variables into Lucene queries. Example parametrized Lucene query: .es(index=pageview_*,metric='sum:value',timefield='timestamp',q='platform: $PLATFORM').label('Current')

Without the fix it was substituted as: .es(index=pageview_*,metric='sum:value',timefield='timestamp',q='platform: {Android,Windows,iOS}').label('Current') which is not a valid Lucene query

After the fix: .es(index=pageview_*,metric='sum:value',timefield='timestamp',q='platform: ("Android" OR "Windows" OR "iOS")').label('Current') Which is what we want

Would you be so kind to merge this?

Regards, Máté

mateczagany commented 5 years ago

Hi,

We have also encountered a bug where the substitution of variables don't work when using breakdown panels and fixed it the same way.

gbrian commented 5 years ago

@czmate10 sorry for the delay. Question why not using: 'platform: ${PLATFORM:lucene}' instead 'platform: $PLATFORM' is same behavior and grafana's standard. If we force globally this lucene type replacement it becomes more rigit, don't you? I'm testing/checking your changes BTW

mateczagany commented 5 years ago

Hi @gbrian You are correct, I didn't know about that advanced formatting, it really did solve my issue. However it didn't solve the problem we have with breakdown panels (see 53e749a )

It seems to always replace the variable with *

In case of a breakdown panel, if I type $PLATFORM, it replaces it, but not with Lucene formatting But if I type ${PLATFORM:lucene} or anything that is not exactly $PLATFORM it will replace it with *