Search code examples
influxdbinfluxql

Influx CLI execute does not find tags in the WHERE clause


I have a series that has some tags in them

> show tag keys on telegraf from mqtt_consumer
name: mqtt_consumer
tagKey
------
host
house_tag
sensorId
topic

and I am using a normal query that works OK within influx command line

select time,value,sensorId,house_tag from mqtt_consumer where time>now()-10m and house_tag='houseG1'

which returns the expected results.

now when I try to run the same query with Influx CLI using the -execute command it returns nothing.

this is the CLI command I am using. I doesn't throw an error, it just returns nothing. Am I writing the query the wrong way? I have tried using double quotes with the house_tag tag but it did not work. When I remove the "house_tag" part, the query runs (but of course it is not only the house_tags that I want to see)

sudo influx -username user -password "password" -database 'database' -host 'localhost' -execute 'select time,value,sensorId,house_tag from mqtt_consumer where time>now()-1d and house_tag='houseG1'' -format 'csv'

Solution

  • The reason why your query is not running is that you are NOT combining double quotes " and single quotes ' within the -execute statement.

    Try running the following query:

    sudo influx -username user -password "password" -database 'database' -host 'localhost' -execute "select time,value,sensorId,house_tag from mqtt_consumer where time>now()-1d and house_tag='houseG1'" -format csv