Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Distinct function in influxDB

I am using influx DB and issuing command,

SELECT * FROM interface

Below is the out put-

interface 
time                              element                path                                       value
2016-08-24T21:22:16.7080877Z    "link-layer-address0"   "key:/arp-information/link-layer-address0"  "3c:61:04:48:df:91"
2016-08-24T21:22:17.9090527Z    "link-layer-address0"   "key:/arp-information/link-layer-address0"  "3c:61:04:48:df:92"
2016-08-24T21:22:19.8584133Z    "link-layer-address1"   "key:/arp-information/link-layer-address1"  "3c:61:04:48:df:97"
2016-08-24T21:22:20.3377847Z    "link-layer-address2"   "key:/arp-information/link-layer-address2"  "3c:61:04:48:df:90"

When issue command it works fine.

SELECT distinct(value) FROM interface 

But When issue command for path column there is no out put. Wondering what i am missing?

SELECT distinct(path) FROM interface 
like image 817
Ammad Avatar asked Aug 29 '16 23:08

Ammad


People also ask

What is group by time in InfluxDB?

It determines how InfluxDB groups query results over time. For example, a time_interval of 5m groups query results into five-minute time groups across the time range specified in the WHERE clause.

What does InfluxDB mean?

MEAN(*) Returns the average field value associated with each field key in the measurement. MEAN() supports int64 and float64 field value data types.


2 Answers

There is SHOW TAG VALUES WITH key = path that one can use to get unique Tag values

like image 138
Alexander Avatar answered Sep 28 '22 08:09

Alexander


There is a way of solving this by using double SELECT statement:

> select distinct("tag1") from (select "field1", "tag1" from foo)

The inner query returns field1 and tag1 which can be queried outside like normal fields for which you can apply distinct().

Hope it helps. Cosmo.

like image 22
Cosmo Avatar answered Sep 28 '22 09:09

Cosmo