Thanks Harkishen for your input.

Issue is resolved and I am able to get data in the query.

Thanks a lot @Robert Collier <[email protected]>  for your support.


On Tue, Mar 16, 2021 at 11:11 PM Harkishen Singh <[email protected]>
wrote:

> Sounds to me like you want to use a result from one query as a label value
> to another query's label key.
> It seems pretty easy if you use SQL (by using Promscale) for this, like
>
> select * from prom_metric.go_goroutines where labels ? ('ifIndex' ==
> (select value from prom_metric.ifName limit 1)::text);
>
> But not sure how to do it in PromQL.
>
> (My previous reply from mail didn't come here, maybe due to some reply
> option selection, so repasting the answer. Sorry for that.)
>
>
> On Tuesday, March 16, 2021 at 7:30:22 PM UTC+5:30 Robert Collier wrote:
>
>> [Moving the list to bcc]
>>
>> You need to reverse the order - the bracketed expression first:
>>
>> (ifName * 0) + on(ifIndex,hostname,instance,job) group_left ifOutOctets
>>
>> I'll follow up separately re the snmp config.
>>
>>
>> On Tue, 16 Mar 2021 at 09:55, Saurabh Jain <[email protected]> wrote:
>>
>>> It is still not working.
>>>
>>>
>>> [image: image.png]
>>>
>>> We used the latest configuration of snmp exporter and generator and
>>> below is the snapshot of the snmp.yml file which was generated by generator.
>>>
>>> [image: image.png]
>>> Pls suggest if we have to tweak the snmp file to achieve the desired
>>> result.
>>>
>>>
>>> On Tue, Mar 16, 2021 at 2:09 PM Robert Collier <[email protected]>
>>> wrote:
>>>
>>>> Ah, reverse it to:
>>>>
>>>> (ifName * 0) + on(ifIndex,hostname,instance,job) group_left ifOutOctets
>>>>
>>>> [image: Screen Shot 2021-03-16 at 8.32.10 AM.png]
>>>>
>>>> *However*, if you are using the regular prometheus snmp_expporter, you
>>>> should be aware that configured correctly it will do this step for you, eg,
>>>> copying directly from my snmp exporters metrics:
>>>>
>>>> # HELP ifOutOctets The total number of octets transmitted out of the 
>>>> interface, including framing characters - 1.3.6.1.2.1.2.2.1.16
>>>> # TYPE ifOutOctets counter
>>>> ifOutOctets{ifAlias="",ifDescr="apcli0",ifIndex="16",ifName="apcli0"} 0
>>>> ifOutOctets{ifAlias="",ifDescr="apclii0",ifIndex="28",ifName="apclii0"} 0
>>>> ifOutOctets{ifAlias="",ifDescr="br0",ifIndex="29",ifName="br0"} 
>>>> 2.7732281e+07
>>>> ifOutOctets{ifAlias="",ifDescr="eth0",ifIndex="2",ifName="eth0"} 
>>>> 2.76292118e+08
>>>> ifOutOctets{ifAlias="",ifDescr="lo",ifIndex="1",ifName="lo"} 1.930652e+06
>>>> ifOutOctets{ifAlias="",ifDescr="ra0",ifIndex="4",ifName="ra0"} 
>>>> 5.37888286e+08
>>>> ifOutOctets{ifAlias="",ifDescr="ra1",ifIndex="5",ifName="ra1"} 0
>>>>
>>>> You may have to regenerate the configuration for it to do that though:
>>>> https://github.com/prometheus/snmp_exporter/blob/main/README.md#generating-configuration
>>>>
>>>> It's been a couple of years since I did the setup now and I don't
>>>> remember the details.
>>>>
>>>>  - Regards, Rob.
>>>>
>>>> On Tue, 16 Mar 2021 at 03:53, Saurabh Jain <[email protected]>
>>>> wrote:
>>>>
>>>>> Not working  . Pls chk below screenshot.
>>>>>
>>>>> [image: image.png]
>>>>>
>>>>>
>>>>> On Tue, Mar 16, 2021 at 12:18 AM Robert Collier <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Something like this maybe?:
>>>>>>
>>>>>> ifOutOctets + on(ifIndex,hostname,instance,job) group_right (ifName *
>>>>>> 0)
>>>>>>
>>>>>> On Mon, 15 Mar 2021 at 16:17, Saurabh Jain <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> Thanks Harry for the update.
>>>>>>>
>>>>>>> ifOutOctets metric  dont have the label ifName.
>>>>>>>
>>>>>>> However I am getting below response for the same.
>>>>>>>
>>>>>>> [image: image.png]
>>>>>>> pls advice.
>>>>>>>
>>>>>>> On Mon, Mar 15, 2021 at 6:00 PM Harry Perks <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Does ifOutOctets have a label ifName? If not, you'll need to
>>>>>>>> perform a vector match operation - it looks like ifIndex can be used:
>>>>>>>>
>>>>>>>> sum by(ifName) (ifOutOctets * on(ifIndex) group_left(ifName) ifName)
>>>>>>>>
>>>>>>>> On Monday, March 15, 2021 at 11:38:41 AM UTC [email protected]
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> I have a certain requirement to implement in Grafana where we need
>>>>>>>>> to show interface utilization for switch.
>>>>>>>>>
>>>>>>>>> I got combination of two queries in order to achieve it
>>>>>>>>>
>>>>>>>>> 1)
>>>>>>>>> ifOutOctets{hostname="XX",ifIndex="103",instance="XX",job="SNMP"}
>>>>>>>>>
>>>>>>>>> 2)
>>>>>>>>> ifName{hostname="XX",ifIndex="103",ifName="Te1/0/1",instance="XX",job="SNMP"}
>>>>>>>>>
>>>>>>>>> First query -- It gives interface utilization on specific index
>>>>>>>>>
>>>>>>>>> Second query --- It gives interface name mapped to specific index
>>>>>>>>>
>>>>>>>>> Now How can I combine both these query in a way that I get
>>>>>>>>> interface utilization on interface name not on index.
>>>>>>>>>
>>>>>>>>> Pls advice.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Saurabh
>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to a topic in
>>>>>>>> the Google Groups "Prometheus Developers" group.
>>>>>>>> To unsubscribe from this topic, visit
>>>>>>>> https://groups.google.com/d/topic/prometheus-developers/PyK8s75e1vE/unsubscribe
>>>>>>>> .
>>>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>>>> [email protected].
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/prometheus-developers/db5825ef-58ba-44f2-b049-ec3050024f9cn%40googlegroups.com
>>>>>>>> <https://groups.google.com/d/msgid/prometheus-developers/db5825ef-58ba-44f2-b049-ec3050024f9cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Prometheus Developers" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/prometheus-developers/CA%2BTEA9DHhD2%3DKx7%3DnTTzfzepcZQ%2BfXEC06QXywazKYK2oZnzaQ%40mail.gmail.com
>>>>>>> <https://groups.google.com/d/msgid/prometheus-developers/CA%2BTEA9DHhD2%3DKx7%3DnTTzfzepcZQ%2BfXEC06QXywazKYK2oZnzaQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Robert Collier
>>>>>> [email protected]
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Prometheus Developers" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/prometheus-developers/CA%2BTEA9Cn5a1_Se1nqqgBF5uzgS-cBn_YYAY8ghPTQ%3D3EJ-qR3A%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/prometheus-developers/CA%2BTEA9Cn5a1_Se1nqqgBF5uzgS-cBn_YYAY8ghPTQ%3D3EJ-qR3A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>
>>>>
>>>> --
>>>> Robert Collier
>>>> [email protected]
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Prometheus Developers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/prometheus-developers/CA%2BTEA9Ca7Cn9dz-OvChKUC%2BoqrUAbRdJuutkXeLfxmiD0AXejA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/prometheus-developers/CA%2BTEA9Ca7Cn9dz-OvChKUC%2BoqrUAbRdJuutkXeLfxmiD0AXejA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>> Robert Collier
>> [email protected]
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Prometheus Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-developers/c12fb859-d26a-4b6a-80e9-4760b7ff0459n%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-developers/c12fb859-d26a-4b6a-80e9-4760b7ff0459n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-developers/CA%2BTEA9AH4m9nnCsWp%3Dt6YY4t5AW3xs6z31a51b4C6FWn-Dws0g%40mail.gmail.com.

Reply via email to