Grafana/Prometheus/snmp_exporter variable queries

Hi folks,

I am a new Grafana and Prometheus user and I want to create 2 variables to generate a customizable bandwidth utilization graph: Device IP (instance) and Interface name (ifName).
I managed to make it work by creating the variables as type Query and using the following query statements:
label_values(instance) - for variable deviceip
label_values(ifName) - for variable ifname

The problem is that I want the “ifname” variable to load only the interface names contained in the “deviceip” selected (instance).

Could someone please lend me a hand?

Thanks,
Marcelo

I have managed to make it work:
$deviceip: label_values({job=“snmp”},instance)
$ifname: label_values({instance=~"$deviceip"},ifName)

Graph query:
irate(ifInOctets{instance=~’$deviceip’,ifName=~’$ifname’}[5m])