# How to join table?

**URL:** <https://community.influxdata.com/t/how-to-join-table/5188>\
**Category:** Systems\
**Created:** [May 16, 2018, 3:45am UTC](https://community.influxdata.com/t/how-to-join-table/5188 "2018-05-16T03:45:48Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvianno](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/alvianno/32/2780_2.png) [@alvianno](https://community.influxdata.com/u/alvianno)\
**Post date:** [May 16, 2018, 3:45am UTC](https://community.influxdata.com/t/how-to-join-table/5188/1 "2018-05-16T03:45:48Z")

</div>

I have db

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/0/07eaeecbb1afdf9b1c9c08f5786004663f5b61a8.png)  
and i have csv  
 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/8/8ea82aa8fe8f00bf4b4f9147d39871747b41182a.png)  
how to join table?

---

<div class="post-metadata">

**Author:** ![dmuiruri](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/dmuiruri/32/1297_2.png) [@dmuiruri](https://community.influxdata.com/u/dmuiruri)\
**Post date:** [May 16, 2018, 8:26am UTC](https://community.influxdata.com/t/how-to-join-table/5188/2 "2018-05-16T08:26:19Z")

</div>

What does “join” mean in this context?

---

<div class="post-metadata">

**Author:** ![alvianno](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/alvianno/32/2780_2.png) [@alvianno](https://community.influxdata.com/u/alvianno)\
**Post date:** [May 16, 2018, 8:31am UTC](https://community.influxdata.com/t/how-to-join-table/5188/3 "2018-05-16T08:31:51Z")

</div>

join “IP” from data csv with tags “IP” in influxdb

---

<div class="post-metadata">

**Author:** ![dmuiruri](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/dmuiruri/32/1297_2.png) [@dmuiruri](https://community.influxdata.com/u/dmuiruri)\
**Post date:** [May 16, 2018, 8:45am UTC](https://community.influxdata.com/t/how-to-join-table/5188/4 "2018-05-16T08:45:15Z")

</div>

Not sure about the context, but it sounds like you are thinking of join in terms of relational tables as in RDBMS. The approach of querying influx or tseries DBs is slightly different where the meaurements(tables) are not related in that sense that joins would apply, probably it is possible to construct the query using logical operators to achieve similar effects. The data in the csv file would however need to be in the influxdb as well.

---

<div class="post-metadata">

**Author:** ![alvianno](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/alvianno/32/2780_2.png) [@alvianno](https://community.influxdata.com/u/alvianno)\
**Post date:** [May 16, 2018, 8:50am UTC](https://community.influxdata.com/t/how-to-join-table/5188/5 "2018-05-16T08:50:06Z")

</div>

soo how to data csv inner join to influxdb?

---

<div class="post-metadata">

**Author:** ![Richard\_Anthony](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@Richard\_Anthony](https://community.influxdata.com/u/Richard_Anthony)\
**Post date:** [May 16, 2018, 9:10am UTC](https://community.influxdata.com/t/how-to-join-table/5188/6 "2018-05-16T09:10:20Z")

</div>

This is the case:  
We have 2 measurement, sitescope and reference (we want to use this table to reference each ip belong to which service/location)

sitescope format: timestamp, ip as (tag), hostname as (tag), monitor\_type as (tag), metric\_name as (tag), and metric\_value as (field)  
Example data: 1526461228, 10.10.x.x, DMxxxx, CPU, utilization, 5

reference: timestamp, ip as (tag), service as (tag), location as (tag), and ref\_status as (field)  
Example: 1526461228, 10.10.x.x, Petshop, DC1, 1

How to combine / join the table so we can query metric\_value based on service/location?

---

<div class="post-metadata">

**Author:** ![dmuiruri](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/dmuiruri/32/1297_2.png) [@dmuiruri](https://community.influxdata.com/u/dmuiruri)\
**Post date:** [May 16, 2018, 9:31am UTC](https://community.influxdata.com/t/how-to-join-table/5188/7 "2018-05-16T09:31:04Z")

</div>

Ok, I see what you mean, thanks for the clarification.

As noted earlier seems no way around this if the measurements are separate, and there are actually no logical operator that allow mimicking a join of sorts.

See this issue: [Frequently asked questions | InfluxDB OSS 1.4 Documentation](https://docs.influxdata.com/influxdb/v1.4/troubleshooting/frequently-asked-questions/#how-do-i-query-data-across-measurements)

---

<div class="post-metadata">

**Author:** ![alvianno](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/alvianno/32/2780_2.png) [@alvianno](https://community.influxdata.com/u/alvianno)\
**Post date:** [May 16, 2018, 9:36am UTC](https://community.influxdata.com/t/how-to-join-table/5188/8 "2018-05-16T09:36:00Z")

</div>

![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/c/c734df7bb10d6e8b077b0111334e4f8fee526278.jpg)  
 ![image](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex023/uploads/influxdata/original/2X/a/a404519cf49503bc312e2a94b8ca8213338a1ee8.jpg)

code :  
// Get errors stream data  
var tes1 = stream  
|from()  
.measurement(‘sitescope.ip’)  
.groupBy(‘ip’)

// Get views stream data  
var tes2 = stream  
|from()  
.measurement(‘reference.ip’)  
.groupBy(‘ip’)

// Join errors and views  
tes1  
|join(tes2)  
.as(‘tes1’, ‘tes2’)  
.fill(0.0)  
.streamName(‘error\_rate’)  
|where(lambda: “tes1.ip” == “tes2.ip”)  
|eval(lambda: “tes1”, lambda: “tes2”)  
.as(‘tes1’, ‘tes2’)  
|influxDBOut()  
.database(‘telegraf’)  
.retentionPolicy(‘autogen’)  
.measurement(‘sitescope’)

---

<div class="post-metadata">

**Author:** ![Richard\_Anthony](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@Richard\_Anthony](https://community.influxdata.com/u/Richard_Anthony)\
**Post date:** [May 16, 2018, 9:53am UTC](https://community.influxdata.com/t/how-to-join-table/5188/9 "2018-05-16T09:53:58Z")

</div>

Thank you very much for your feedback.

Actually we can solve the problem by running script like this with Kapacitor and it’s actually working fine:

stream  
|from()  
.database(‘telegraf’)  
.measurement(‘sitescope’)  
.groupBy(‘ip’)  
|where(lambda: “ip” == ‘10.10.11.31’ OR  
“ip” == ‘10.10.11.32’ OR  
“ip” == ‘10.10.12.31’ OR  
“ip” == ‘10.10.12.32’)  
|eval(lambda: ‘Petshop’)  
.as(‘service’)  
.tags(‘service’)  
.keep()  
|delete()  
.field(‘service’)  
|influxDBOut()  
.database(‘telegraf’)  
.retentionPolicy(‘autogen’)  
.measurement(‘sitescope’)

But the problems are, spesific and hard-coded script like that will be difficult to maintain for long-term in production stage.  
Our idea is to make reference table so we only need to update the table instead of the script, so it will be easier to maintain.  
What do you think? Is there any other solution?

---

<div class="post-metadata">

**Author:** ![dmuiruri](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/dmuiruri/32/1297_2.png) [@dmuiruri](https://community.influxdata.com/u/dmuiruri)\
**Post date:** [May 16, 2018, 10:05am UTC](https://community.influxdata.com/t/how-to-join-table/5188/10 "2018-05-16T10:05:09Z")

</div>

It seems all potential solutions at the moment can only be found “external” to the database itself due to the known limitation.

The solution you have at the moment seems to produce your desired results atleast with a solution found at another part of the larger stack. I would have also suggested mangling the data with other tools e.g pandas and then storing the data back into influxdb with the desired structure. Again not optimal since that is another script and tool you introduce.

---

<div class="post-metadata">

**Author:** ![NAIVniy](https://avatars.discourse-cdn.com/v4/letter/n/8797f3/32.png) [@NAIVniy](https://community.influxdata.com/u/NAIVniy)\
**Post date:** [October 2, 2018, 12:52pm UTC](https://community.influxdata.com/t/how-to-join-table/5188/11 "2018-10-02T12:52:28Z")

</div>

Hi, Alvianno!  
I’m new to IndfluxDB, and as fas as i can see - you integrated your sitescope to indluxdb.  
Could you please tell me, how did you did it? I’m looking for the best way to collect data from sitescope to influxdb, but i had never used RDBMS to store sitescope data.  
Thank you for your help!

---

<div class="post-metadata">

**Author:** ![samaust](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/samaust/32/867_2.png) [@samaust](https://community.influxdata.com/u/samaust)\
**Post date:** [October 5, 2018, 2:30am UTC](https://community.influxdata.com/t/how-to-join-table/5188/12 "2018-10-05T02:30:05Z")

</div>

Take a look at Kapacitor SideloadNode. It allows to load fields and tags values from a file selected based on a tag value.

Another option is Telegraf Enum processor plugin :

> **[telegraf/plugins/processors/enum at release-1.8 · influxdata/telegraf](https://github.com/influxdata/telegraf/tree/release-1.8/plugins/processors/enum)**
>
> release-1.8/plugins/processors/enum
