Problems Select From Where


I am a newbie, trying to use Grafana.

I am collecting temp/humidity data from several sensors with NodeRed and storing them in InfluxDB.

When I plot them using Grafana, the following sentences gives an empty graph:

SELECT mean(“temp”) FROM “autogen”.“sensors” WHERE (“sensorID” = ‘1’) GROUP BY time($__interval) fill(null)

while this works:
SELECT mean(“temp”) FROM “autogen”.“sensors” WHERE GROUP BY time($__interval) fill(null)

When I catch the mqtt on NodeRed, I receive a JSonFormat, like {“sensorID”:99,“temp”:23.25919,“hum”:54.15326,“pressure”:101.0474,“illuminance”:33.87097,“uva”:0,“uvb”:0,“uvIndex”:0}

Then I parse it to a JsonObject, and send it to the InfluxDB Data-Base, as InfluxDB adds automatically a timestep.

My problem is, I have several sensors (tag: sensorID, and value 1, 2, 3, …). And I would like to print the temperatura stuff for each sensor independently.

Did I build the DB the wrong way?

Should the sensorID be a string, like “sens1”, “sens2”,…

Because, if I use:
SELECT mean(“temp”) FROM “sensors” WHERE (“sensorID” > 1) AND $timeFilter GROUP BY time(5m) fill(null)

it works.


sensorID value is a int, not a string so you need to use int condition “sensorID” = 1 and not string condition “sensorID” = ‘1’ (see quotes around number).

Thanks jangaraj.

But everytime I edit the value not as a sql command, it turns to string, and I have to remove manually the quotes.

By the way, thanks for your time :slight_smile: Grafana is awesome :slight_smile: And this community is just wonderful!

Switch to raw query. Don’t use editor but write/edit query manually.