Search code examples
urlgrafanainfluxdb

InfluxDB query doesn't work with the "WHERE" clause


I have a problem with WHERE clause in the URL query. Shortly, this works:

http://localhost:8086/query?pretty=true&db=boatdata&q=SELECT time,lat FROM "navigation.position" WHERE time='2021-05-19T11:21:11.448Z'

this doesn’t:

http://localhost:8086/query?pretty=true&db=boatdata&q=SELECT time,lat FROM "navigation.position" WHERE lon='23.53815'

Difference: in first statement I use ‘time’ in the WHERE clause, and in second one I use ‘lon’ instead:

WHERE time='2021-05-19T11:21:11.448Z' vs. WHERE lon='23.53815'

It doesn’t make sense to me why the second one doesn’t work. Any help would be much appreciated. Thanks.

P.S. Here’s an output of these two: #1:

{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "name": "navigation.position",
                    "columns": [
                        "time",
                        "lat"
                    ],
                    "values": [
                        [
                            "2021-05-19T11:21:11.448Z",
                            60.084066666666665
                        ]
                    ]
                }
            ]
        }
    ]
}

#2

{
    "results": [
        {
            "statement_id": 0
        }
    ]
}

Solution

  • It makes sense - lat (lon) is not a string type.

    Filtering, where lat is a string type:

    lat='60.084066666666665'
    

    vs. filtering, where lat is a float type:

    lat=60.084066666666665