Hi,
I am trying to build a dashboard which has a variable desription as Dashboard variable. This variable is sourced by a postgres DB and has 3 fields. “Description”,“host_name”,“service_description” .
The Dashboard user selects “Description” and should get Data from influx bucket filter by tag host_name and service_description.
Where i am stuck now to get a variable from the sql.from used in the 2nd flux query . ( in this try host_name only )
This is what i came up with ( mostly search and trial and error ) . sry for this …
( $description is alread set from the grafana Dashboard this works )
getInput = (mylist) => {
_idRecord = sql.from(
driverName: “postgres”,
dataSourceName: “postgresql://grafana:password@127.0.0.1?sslmode=disable”,
query: “SELECT host_name FROM interfaces where description=‘${description}’”,
)
|> findRecord(idx: 0, fn: (key) => true)
return _idRecord.host_name
}
input_host_name = getInput(mylist: v.host_name)
But i get an error that “v.host_name” is undefined .
The select returns 1 single host_name = “myhostname” .
In the flux query i would like to use then
|> filter(fn: (r) => r[“host_name”] == input_host_name)
Thx for any help or hints. Still beginner .
The hole Idea behind is that the Dashboard User should only see those host with services listed in the sql DB and should not see the real host and serivces names . ( only eg parts Services from 1 host ) . The influx is feeded by checkmk with host_name,interface(service_description) . ( Interface Traffic )
Best regards, Dietmar