Problem with Influxdb Script in Grafana

Hello

Once again I have a small problem for beginners.
I am trying to insert the generated script from my Influxdb into Grafana but I get an error message


from(bucket: "home_assistant/autogenous")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "kWh")
  |> filter(fn: (r) => r["entity_id"] == "abc")

If I insert this now, I get this error message in Grafana:

InfluxDB returned error: error parsing query: found FROM, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1

Unfortunately, my current knowledge ends here and I don’t know what to do.
Can someone please tell me what I am doing wrong here?

Thank you very much for your help and efforts.
Mandragora

Looks like your influxdb is expecting “InfluxQL” (a SQL lookalike) and not Flex as the query language.

See, e.g., Flux vs InfluxQL | InfluxDB Cloud (TSM) Documentation

Hello

If I try the same with InfluxQL code I also get an error message.

Is there a setting somewhere in the InfluxDB where I can change / set the query to Flux.
I have set up my Homeassistant with InfluxDB and Grafana according to the usual instructions that can be found on the Internet.
So far everything is working and I get data from the Homeassistant into the database.
Many instructions then show you how to insert the code from InfluxDB into Grafana.
That’s why I want to try this here to learn.

Thank you for the help.

In the configuration of your influxdb datasource in grafana:

Thank you koying

When i changed the settings to flux i get this error message

I have tried it with user and password and also without basic auth.

I was only able to restore the settings from the backup so that it worked again.

sorry for my beginner problems.