Join Data from 2 Different Datasources

Hi,

I have tried to use Dashboard Variables only for the solution i would like to have .

( my first forum post : Dashboard Variables ) .

But i think i made it wrong, and i need to join 2 different Datasources and filter after ( the point i miss ) .

The reason for all this is we need a “Custom Business Like Description” to a “host_name , service_description tag” in influx . We cannot add this description to influxdb itself.

( Take the Description in the csv as selection to pull data from influx with the tag of host_name and service_description + time from demo3-in and demo3-out series)

To be able to reproduce i have tried to build csv Data to load into influx .

demo3-in,region=1,host_name=Hostname1,service_description=Interface1 fieldkey=12
demo3-out,region=1,host_name=Hostname1,service_description=Interface1 fieldkey=42
demo3-in,region=1,host_name=Hostname1,service_description=Interface2 fieldkey=12
demo3-out,region=1,host_name=Hostname1,service_description=Interface2 fieldkey=42
demo3-in,region=2,host_name=Hostname2,service_description=Interface1 fieldkey=22
demo3-out,region=2,host_name=Hostname2,service_description=Interface1 fieldkey=52
demo3-in,region=2,host_name=Hostname2,service_description=Interface2 fieldkey=22
demo3-out,region=2,host_name=Hostname2,service_description=Interface2 fieldkey=52
demo3-in,region=3,host_name=Hostname1,service_description=Interface3 fieldkey=32
demo3-out,region=3,host_name=Hostname1,service_description=Interface3 fieldkey=62
demo3-in,region=3,host_name=Hostname1,service_description=Interface3 fieldkey=32
demo3-out,region=3,host_name=Hostname1,service_description=Interface3 fieldkey=62
demo3-in,region=4,host_name=Hostname2,service_description=Interface3 fieldkey=42
demo3-out,region=4,host_name=Hostname2,service_description=Interface3 fieldkey=72
demo3-in,region=4,host_name=Hostname2,service_description=Interface4 fieldkey=42
demo3-out,region=4,host_name=Hostname2,service_description=Interface4 fieldkey=72

The 2nd query is a grafana csv query to show what it is needed ( production would be postgres ) .

cat demo.txt
Region,Description,host_name,service_description
“1”,“Line to 1”,“Hostname1”,“Interface1”
“1”,“Line to 2”,“Hostname1”,“Interface2”
“2”,“Line to 3”,“Hostname2”,“Interface1”
“2”,“Line to 4”,“Hostname2”,“Interface2”
“3”,“Line to 5”,“Hostname1”,“Interface3”
“3”,“Line to 6”,“Hostname3”,“Interface2”
“4”,“Line to 7”,“Hostname2”,“Interface3”
“4”,“Line to 8”,“Hostname2”,“Interface4”

I have added with the csv datasource a dashboard variable to select the “Description” field ( Line to x ) .

I am able to query both and i have the description field from the csv as pull down .

mix query:

query1:

SELECT mean(“fieldkey”) FROM “demo3-out” WHERE $timeFilter GROUP BY time(5m), “host_name”::tag, “service_description”::tag fill(none)

query2:

SELECT mean(“fieldkey”) FROM “demo3-in” WHERE $timeFilter GROUP BY time(5m), “host_name”::tag, “service_description”::tag fill(none)

query3 :
csv

The result query should be timeseries data from the InfluxDB + description from the csv . ( key = host_name,service_description ) , and filter by the set Dashboard Variable (description)

I have tried with transform join data by field ( inner , outa ) , but it seems not to work .

I only got it working with the 2 same datasource demo3-in and demo3-out based on time.

Thx for any help ,

Best regads, Dietmar

Hi,

I tried to do the query and the join ( failed ) in flux, because i think i would those featues anyway.

As a (not) Programmer it is rather difficult for me to get this done .

code:

download = from(bucket: “checkmk”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “demo3-out”)
|> filter(fn: (r) => r[“_field”] == “fieldkey”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)

upload = from(bucket: “checkmk”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “demo3-in”)
|> filter(fn: (r) => r[“_field”] == “fieldkey”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)

all = join(tables: {download: “demo3-out”, upload: “demo3-in”}, on: [“_time”,“host_name”,“service_description”], method: “inner”)
|> yield(name: “all”)

output expected to be : demo3-out.value , demo3-in.value , host_name,service_description,_time,_start,_stop

The Queries are working and i could yield them, but i tried different way’s for this simple join and it is not working .

It throws an error : ``` error calling function “join” @14:7-14:134: expected “download” to be stream type; instead got string

thx, Dietmar