Return data from multiple measurements into a single data view

Hi there,

I have several measurements (tables) and I’m using the following query to return the data:

SELECT * FROM memory_stats,agent_stats WHERE cuid = 'DOEX71LNRBXEVQ2UIUHYCUX' LIMIT 1

When doing this query in the Influxdb CLI I get the following:

> SELECT * FROM memory_stats,agent_stats WHERE cuid = 'DOEX71LNRBXEVQ2UIUHYCUX' LIMIT 1
name: agent_stats
-----------------
time                            cuid                    guid            heap    memory  reason  state
2017-08-02T13:41:38.510990346Z  DOEX71LNRBXEVQ2UIUHYCUX DOEX71LNR                               USER_LOGIN


name: memory_stats
------------------
time                            cuid                    guid            heap    memory  reason  state
2017-08-02T13:41:55.873818934Z  DOEX71LNRBXEVQ2UIUHYCUX DOEX71LNR       85.53   51.57

When querying via the HTTP API I get the following:

[
  {
    "cuid": "DOEX71LNRBXEVQ2UIUHYCR7",
    "guid": "DOEX71LNR",
    "heap": null,
    "memory": null,
    "reason": "",
    "state": "USER_LOGIN",
    "time": "2017-08-02T13:41:27.152Z"
  },
  {
    "cuid": "DOEX71LNRBXEVQ2UIUHYCR7",
    "guid": "DOEX71LNR",
    "heap": 60.87,
    "memory": 40.75,
    "reason": null,
    "state": null,
    "time": "2017-08-02T13:41:41.966Z"
  }
]

How can I specify an Influxdb query that would return the results as a single data view? (e.g. without the null values or duplicate measurements)

I need this data as a single view to “selectively” populate a table in my application.

Any suggestions?

Regards,

Antonio.

I think the first place to start with is to group these results by time. e.g. group by a time window, say same query but group it by 5 minutes.

Also with the time grouping you can define the behavior of “Null” to “None” using the “fill” function:

@sbains do you have a more specific query example I could use?

Hi Antonio,

I could be wrong here; I didn’t pay attention to the fact that it is a multi measurement query you have referred here. But try the following:

SELECT * FROM memory_stats,agent_stats WHERE cuid = ‘DOEX71LNRBXEVQ2UIUHYCUX’ where time > group by time(5m) fill(none)

The time window can be modified (1h) or (1d) or something else.

I’m afraid the query didn’t work for me, I got an “error parsing the query”. There seems to be 2 WHERE clauses.

Yeah ur right. Try the following

SELECT * FROM memory_stats,agent_stats WHERE cuid = ‘DOEX71LNRBXEVQ2UIUHYCUX’ and time > and time < group by time(5m) fill(none)