Query error in Grafana using query script from Influxdb

Hi newbie here trying to understand and make create dashboard. I can create a graph in Influxdb, but I cannot recreates the same graph in Grafana using the script from influxdb

`from(bucket: “HomeAssistant”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“entity_id”] == “home_energy”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> filter(fn: (r) => r[“_measurement”] == “kWh”)
|> filter(fn: (r) => r[“domain”] == “sensor”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: true)
|> yield(name: “mean”)

I receive error in grafana `invalid: error @1:13-1:28: found unexpected argument Bucket’

Any help would be appreciated, is there away of copy pasting the script from Influxdb to Grafana .

Hi @mikey6283

If you can see the graph in Influx Data Explorer, and you have carefully copied/pasted the Flux query into Grafana, then it should normally work there as well. From the error you have listed, it appears your first line contains the error. Do you have any extra characters? It appears it should be as follows:

from(bucket: “HomeAssistant”)

but (at least in your post) you have a ' character present

Hi grant1 , thanks for reply I think that you solved my problem, however, i was using the space bar instead of tapping when creating the pipe. I think this was one of my main problem. I will now be more careful. Is there away to copy and paste into Grafana as it doesn’t work for me?

Glad it worked. As for copy/paste, I just highlight over the Flux query and hit CTRL-C (on Windows) and then CTRL-V in Grafana.

1 Like