Different result between Chronograf query vs HTTP query

Hi there,
I am on Influxdb 1.7.10 with Chronograf 1.7.17.

I perform this query:

SELECT first(“temperature”) AS “T”,first(“humidity”) AS “H” FROM “ttndb”.“autogen”.“floor” WHERE time > :dashboardTime: AND time < :upperDashboardTime: GROUP BY time(30m), “name” FILL(null)

And I obtain a table with 3 columns: time, t,h and name.

However when I perform the same exact query via the HTTP REST API, the name field which is the group operator disappears.

**
query?pretty=true&db=ttndb&q=SELECT FIRST(“temperature”) AS Temperature,FIRST(“humidity”) AS Humidity FROM “floor” WHERE time <= now() AND time >= now() - 24h GROUP BY time(30m),“name” LIMIT 10"
**

[
{
“time”: “2020-10-08T15:00:00Z”,
“Temperature”: 19.8,
“Humidity”: 60.5
},
{
“time”: “2020-10-08T15:30:00Z”,
“Temperature”: 19.4,
“Humidity”: 60.5
},…
]

Why is that and is there a workaround?

Cheers.

my guess is the comma needs to be URL encoded.

Right now it looks like this:

query?pretty=true&db=ttndb&q=SELECT%20FIRST(%22temperature%22)%20AS%20Temperature%2CFIRST(%22humidity%22)%20AS%20Humidity%20FROM%20%22floor%22%20WHERE%20time%20%3C%3D%20now()%20AND%20time%20%3E%3D%20now()%20-%201w%20%20GROUP%20BY%20time(30m)%2C%22name%22%20LIMIT%20100

I think is encoded right?

that looks right. I attempted to duplicate what you’ve done.

I used via Chronograf 1.8.6:

FROM "telegraf"."autogen"."cpu" 
WHERE time > :dashboardTime: AND time < :upperDashboardTime: 
GROUP BY time(30m), "host" FILL(null)

Subset of results looks like this:

time cpu.system cpu.user host
2020-05-01T07:00:00.000Z 0.992063492 2.610441765 ip-172-31-21-18.ec2.internal
2020-05-01T07:00:00.000Z 0 0 ip-172-31-27-248
2020-05-01T07:00:00.000Z 0.5 1.901901902 ip-172-31-28-115
2020-05-01T07:00:00.000Z 0.994035786 2.621359224 ip-172-31-44-100.ec2.internal
2020-05-01T07:00:00.000Z 0 0.1 ip-172-31-5-238
2020-05-01T07:00:00.000Z 1.185770752 1.787394168 ip-172-31-93-202.ec2.internal
2020-05-01T07:00:00.000Z 1.178781925 2.689243026 telegraf-polling-service
2020-05-01T07:30:00.000Z 0.898203593 2.284011916 ip-172-31-21-18.ec2.internal
2020-05-01T07:30:00.000Z 0 0 ip-172-31-27-248
2020-05-01T07:30:00.000Z 0.401606426 1.70682731 ip-172-31-28-115
2020-05-01T07:30:00.000Z 1.197604791 2.087475151 ip-172-31-44-100.ec2.internal
2020-05-01T07:30:00.000Z 0 0.1001001 ip-172-31-5-238
2020-05-01T07:30:00.000Z 0.701402806 2.004008016 ip-172-31-93-202.ec2.internal
2020-05-01T07:30:00.000Z 0.897308076 2.284011916 telegraf-polling-service
2020-05-01T08:00:00.000Z 0.796019901 2.279484639 ip-172-31-21-18.ec2.internal
2020-05-01T08:00:00.000Z 0 0 ip-172-31-27-248
2020-05-01T08:00:00.000Z 0.401606426 1.606425702 ip-172-31-28-115
2020-05-01T08:00:00.000Z 1.098901099 2.297702296 ip-172-31-44-100.ec2.internal
2020-05-01T08:00:00.000Z 0 0.2 ip-172-31-5-238
2020-05-01T08:00:00.000Z 1.19760479 1.896207584 ip-172-31-93-202.ec2.internal
2020-05-01T08:00:00.000Z 0.798403194 2.186878728 telegraf-polling-service
2020-05-01T08:30:00.000Z 0.796812749 2.19123506 ip-172-31-21-18.ec2.internal
2020-05-01T08:30:00.000Z 0 0 ip-172-31-27-248
curl -XPOST 'https://my_influxdb:8086/query?u=my_username&p=my_password&pretty=true' --data-urlencode 'q=SELECT first("usage_system") AS "system",first("usage_user") AS "user" FROM "telegraf"."autogen"."cpu" WHERE time > now()-169d AND time < now()-138d GROUP BY time(30m), "host" FILL(null)'

(note: I didn’t add the LIMIT 10 here).

Results:

{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "name": "cpu",
                    "tags": {
                        "host": "ip-172-31-21-18.ec2.internal"
                    },
                    "columns": [
                        "time",
                        "system",
                        "user"
                    ],
                    "values": [
                        [
                           "2020-05-01T02:30:00Z",
                            1.0989010981726326,
                            2.1999999997206032
                        ],
                        [
                            "2020-05-01T03:00:00Z",
                            0.8937437930957314,
                            2.0854021842753934
                        ],
                        [
                            "2020-05-01T03:30:00Z",
                            0.7007007006242959,
                            2.0100502513562315
                        ],
                        [
                            "2020-05-01T04:00:00Z",
                            0.6951340616178079,
                            2.383316782359324
                        ],
                        [
                            "2020-05-01T04:30:00Z",
                            0.7881773401777626,
                            2.385685884033873
                        ],
...

So, this looks like the same output to me. I think perhaps what you are missing is that the series are returned by host (in my case…and “name” in yours). The description of the series and associated fields is provided in that header at the very top…and it repeats when the series key changes. So in my case, I see another series appear like this:

...
  {
                    "name": "cpu",
                    "tags": {
                        "host": "telegraf-polling-service"
                    },
                    "columns": [
                        "time",
                        "system",
                        "user"
                    ],
                    "values": [
                        [
                            "2020-05-01T02:30:00Z",
                            1.0999999998603016,
                            2.2044088164337197
                        ],
...

Hopefully that helps!

2 Likes