Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Dashboard variable does not work in v7.0.0 #102

Open
ElieLiabeuf opened this issue May 21, 2020 · 16 comments
Open

Dashboard variable does not work in v7.0.0 #102

ElieLiabeuf opened this issue May 21, 2020 · 16 comments
Labels
bug Something isn't working

Comments

@ElieLiabeuf
Copy link

After upgrading to Grafana 7.0 and using the version 7.0.0, dasboard variable seems to be broken.

With Grafana 6.7 and plugin v5.4.1 I was able to run query like so

from(bucket: "netdata")
  |> range(start: -20m)
  |> filter(fn: (r) => r._measurement =~ /system.cpu$/)
  |> group(columns:["hostname"])
  |> distinct(column:"hostname")
  |> keep(columns: ["_value"])
  |> group()

in the dashboard settings > variables and using the text input "Query".

In the last release it seems that the query is not even executed, no error and no log.

@jhunthrop jhunthrop added the bug Something isn't working label May 22, 2020
@ryantxu
Copy link
Member

ryantxu commented May 31, 2020

In the example above, what is the template varable? In 7.0 the queries should still expand template variables:
https://github.com/grafana/influxdb-flux-datasource/blob/master/src/DataSource.ts#L27

@jjkrol
Copy link

jjkrol commented Jun 1, 2020

In my case, the problem (compared to the previous release) is related to repeating panels using multiple-value variables.

E.g. I have a temperature that I display for each $room selected, so I used to have a repeated panel along the $room variable and a query like:

from(bucket: "edited")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "sensors")
  |> filter(fn: (r) => r.room == "$room")
  |> filter(fn: (r) => r._field == "temperature")

Grafana used to to render each panel, substituting the $room variable with a single value (different one for each repeated panel). Now, it is doing this instead:

from(bucket: "edited") 
|> range(start: v.timeRangeStart, stop: v.timeRangeStop) 
|> filter(fn: (r) => r._measurement == "sensors") 
|> filter(fn: (r) => r.room == "{bathroom,bedroom}") 
|> filter(fn: (r) => r._field == "temperature")

However, the panel title displays the variable correctly.

I have noticed a similar issue in Grafana here, but it's been fixed in 6.1.0.

@ryantxu
Copy link
Member

ryantxu commented Jun 1, 2020

Ahh -- the case you mention here should be fixed for this panel in 7.1. Strangely, it will be fixed by:
grafana/grafana#25123

The real issue is using the panel tenplate vars not just the dashboard vars:
https://github.com/grafana/grafana/pull/25123/files#diff-a3eb83e5943c7013877015636bfef622R130

@jjkrol
Copy link

jjkrol commented Jun 1, 2020

Thank you @ryantxu - I'm looking forward to the release!

@ElieLiabeuf
Copy link
Author

ElieLiabeuf commented Jun 2, 2020

@ryantxu There is no template variable in my query. The query is used to populate a multi-value variable named "hostname".

Here is the configuation:
image

And the preview is empty:
image

The exact same thing used to work in 6.7.

The query itself works fine:
image

@maxirosson
Copy link

Having the same issue mentioned on the last comment.

@seanlok
Copy link

seanlok commented Jul 12, 2020

Having the same issue with @ElieLiabeuf
The query has return from flux query in influx UI but not Grafana variable query

@ryantxu
Copy link
Member

ryantxu commented Jul 13, 2020

Can you try using the 7.1 beta release, and the built-in Influx datasource there?

If it is still an issue, let me know

@hugodlg
Copy link

hugodlg commented Jul 23, 2020

It's still not working. It's not even possible to add a template variable.

Screenshot from 2020-07-23 07-59-10

InfluxDB logs:
logs influxdb

(using grafana 7.1.0 and the latest release from influxDB 2.0.0 beta)

@poldown

This comment has been minimized.

@hugodlg
Copy link

hugodlg commented Jul 23, 2020

@poldown you mean the token from influxdb? i used it on the datasource configuration.
The error only happens when adding template variables. The queries are working fine on the dashboard panels.

I think it's proxying the wrong way too. Let's wait..

@hugodlg
Copy link

hugodlg commented Jul 24, 2020

this is the request that happens when focusing out the query field:

POST /api/v2/query?epoch=ms HTTP/1.1
Host: influxdb:9999
User-Agent: Grafana/7.1.0
Content-Length: 5
Accept: application/json, text/plain, /
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
Authorization: Basic Og==
Content-Type: application/x-www-form-urlencoded
X-Forwarded-For: <IP_ADDR>, <IP_ADDR>
X-Grafana-Org-Id: 1

@poldown
Copy link

poldown commented Jul 26, 2020

Verified - I have the same error as @hugodlg
Testing with Grafana 7.1.0 & InfluxDB 2.0.0 (beta12).

@pedrojr-fit
Copy link

pedrojr-fit commented Aug 21, 2020

Hi, I'm facing the same issue. Is there any fix or workaround for ? I'm using the version of Grafana 7.1.4 & InfluxDB 1.8.1

@andig
Copy link

andig commented Aug 21, 2020

I‘ve given up on Geafana and switched to Cronograf :/

@pedrojr-fit
Copy link

pedrojr-fit commented Aug 22, 2020

This is my workaround for this issue. I'm replacing the string from the filter and as it's a string, I'm transforming the string into a regex using regexp.compile.

`import "strings"
import "regexp"

// Workaround to Replace invalid filter characters from Grafana in order
// to build a valid Regex to be used on Flux Filter
V_EID = strings.replace(v: "$EID", t: "{", u: "^(", i: -1)
V_EID_2 = strings.replace(v: V_EID, t: ",", u: ")|(", i: -1)
V_EID_3 = strings.replace(v: V_EID_2, t: "}", u: ")", i: -1)

from(bucket: "database")
|> range(start: -600d)
|> filter(fn: (r) => r._measurement == "ptable" and (r._field == "ETX_P+L"))
|> filter(fn: (r) => r["EID"] =~ regexp.compile(v: V_EID_3))
`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants