This code not working, "linkid " is stream.
import "influxdata/influxdb/schema"
linkid = schema.tagValues(
bucket: "cur",
tag: "LinkedAccountId",
predicate: (r) => r._measurement == "test" and r.LinkedAccountName == "Test1"
)
from(bucket: "billing")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "costs")
|> filter(fn: (r) => r["UsageAccountId"] == linkid)
|> drop(columns: ["usage_type", "itemId", "service"])
|> sum()
|> yield()
runtime error @11:6-11:54: filter: cannot compile @ 11:17-11:53: unsupported binary expression string == stream
How can I solve the issue?
grant1
2
Hi @Yevhenii_Krainiukov
Can you put the variable (linkid) here?

If you are using Grafana, then approach would be different (I can explain, but maybe you already know how it’s done there or do not use Grafana)
No, linkid is not represented in variables.
Yes, I linked the two variables in Grafana).
But it is very interesting how exactly to do this with Flux.
grant1
4
The approaches in Grafana and Flux are different.
In Grafana, have you got this working?
so that you have a drop down in the dashboard to select the linkid that is used in your query?
grant1
6
Is the drop down in the dashboard to select the linkid working, ie does it show the values you expect?
Everything works as expected.
Solution, write custom function:
import “influxdata/influxdb/schema”
accountname = (AccountId) => {
name = schema.tagValues(bucket: “bill”, tag: “LinkedAccountName”, predicate: (r) => r._measurement == “DBR” and r.LinkedAccountId == AccountId)
acc = name |> findColumn(fn: (key) => true, column: “_value”)
return acc[0]
}
from(bucket: v.bucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “CUR”)
|> filter(fn: (r) => r[“service”] =~ /(?:ppp.+)|(?:PPP.+)/)
|> map(fn: (r) => ({ r with UsageAccountId: accountname(AccountId: r.UsageAccountId)}))
|> sum()
|> pivot(rowKey: [“_value”], columnKey: [“UsageAccountId”], valueColumn: “_value”)