Snmp exporter - several labels for one metric

89 views
Skip to first unread message

Виталий Ковалев

unread,
Mar 1, 2020, 9:08:54 PM3/1/20
to Prometheus Users
Hello.
On  my network i have some specific devices(Optical Receivers), which violate usual snmp rules.
For example - When you do snmpwalk on IF-MIB::IfSpeed OID you get many values in this format:
IF-MIB::ifSpeed.X = Gauge32: 10000000
Where X Number of Interface.

My devices have other logic. They have several oids for one metric(for example optical signal power on inputs(total inputs-2)):
OPTICAL_INPUT1: 1.3.6.1.4.1.32108.1.9.2.2.0
OPTICAL_INPUT2: 1.3.6.1.4.1.32108.1.9.2.3.0

How i can write it in one metric with several label for port? I want output something like this:
FiberRxPower{portIndex="1"} -999
FiberRxPower{portIndex="2"} -36

Brian Brazil

unread,
Mar 2, 2020, 1:57:16 AM3/2/20
to Виталий Ковалев, Prometheus Users
On Mon, 2 Mar 2020 at 02:08, Виталий Ковалев <kvp9...@gmail.com> wrote:
Hello.
On  my network i have some specific devices(Optical Receivers), which violate usual snmp rules.

Why do you think they violate SNMP rules? Can you share the MIB?

Brian

 
For example - When you do snmpwalk on IF-MIB::IfSpeed OID you get many values in this format:
IF-MIB::ifSpeed.X = Gauge32: 10000000
Where X Number of Interface.

My devices have other logic. They have several oids for one metric(for example optical signal power on inputs(total inputs-2)):
OPTICAL_INPUT1: 1.3.6.1.4.1.32108.1.9.2.2.0
OPTICAL_INPUT2: 1.3.6.1.4.1.32108.1.9.2.3.0

How i can write it in one metric with several label for port? I want output something like this:
FiberRxPower{portIndex="1"} -999
FiberRxPower{portIndex="2"} -36


Виталий Ковалев

unread,
Mar 2, 2020, 8:54:42 PM3/2/20
to Prometheus Users
Of course. Here is it.

понедельник, 2 марта 2020 г., 18:57:16 UTC+12 пользователь Brian Brazil написал:

Brian Brazil

unread,
Mar 3, 2020, 2:57:37 AM3/3/20
to Виталий Ковалев, Prometheus Users
On Tue, 3 Mar 2020 at 01:54, Виталий Ковалев <kvp9...@gmail.com> wrote:
There is no FiberRxPower in that MIB. I'm guessing you meant input1Power and input2Power?

There's no table for these, so I'd suggest leaving it as-is and dealing with it in PromQL.

Brian
 
--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/359890fa-9c5d-451e-8a89-6d9f0c557b05%40googlegroups.com.


--

Виталий Ковалев

unread,
Mar 3, 2020, 4:05:12 PM3/3/20
to Prometheus Users
FiberRxPower is just name for the metic.
It's very sad that there is'nt such functional in snmp_exporter.
Maybe i should open a featureRequest on github?
However, thanks for help.

понедельник, 2 марта 2020 г., 14:08:54 UTC+12 пользователь Виталий Ковалев написал:

Ben Kochie

unread,
Mar 3, 2020, 4:25:51 PM3/3/20
to Виталий Ковалев, Prometheus Users
There's no function because it's intended for PromQL to deal with these issues. Metrics exporters are designed to provide the data as raw as possible to avoid second guessing the underlying data.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.

Виталий Ковалев

unread,
Mar 3, 2020, 10:50:47 PM3/3/20
to Prometheus Users
Maybe I misunderstood you?
As i know promql is just a query language. How it will help me?

понедельник, 2 марта 2020 г., 14:08:54 UTC+12 пользователь Виталий Ковалев написал:
Hello.

Виталий Ковалев

unread,
Mar 3, 2020, 10:53:20 PM3/3/20
to Prometheus Users
Maybe i can do that with relabeling in configuration file?


понедельник, 2 марта 2020 г., 14:08:54 UTC+12 пользователь Виталий Ковалев написал:
Hello.

Виталий Ковалев

unread,
Mar 4, 2020, 3:05:15 AM3/4/20
to Prometheus Users
I think i have solved the problem.
Here is my config for snmp_exporter:

tuz_2003:
 
get:
 
- 1.3.6.1.4.1.32108.1.9.2.2.0
 
- 1.3.6.1.4.1.32108.1.9.2.3.0
 
- 1.3.6.1.4.1.32108.1.9.2.4.0
 
- 1.3.6.1.4.1.32108.1.9.2.5.0

  metrics
:
 
- name: FiberRxPower1
    oid
: 1.3.6.1.4.1.32108.1.9.2.2.0
    type
: gauge
    help
: Optical signal level for both ports.

 
- name: FiberRxPower2
    oid
: 1.3.6.1.4.1.32108.1.9.2.3.0
    type
: gauge
    help
: Optical signal level for both ports.

 
- name: RfSignalLevel
    oid
: 1.3.6.1.4.1.32108.1.9.2.4.0
    type
: gauge
    help
: Output RF Signal.

 
- name: Temperature
    oid
: 1.3.6.1.4.1.32108.1.9.2.5.0
    type
: gauge
    help
: Internal device temperature.

  auth
:
    community
: SNMPMTS

  version
: 1


And here is my config for Prometheus:

scrape_configs:

 
- job_name: tuz_2003
    metrics_path
: /snmp
    params:
      module: [tuz_2003]
    file_sd_configs:
        - files :
          - /
etc/prometheus/tuz_2003.yml
          refresh_interval
: 2m
    relabel_configs
:
     
- source_labels: [__address__]
        target_label
: __param_target
     
- source_labels: [__param_target]
        target_label
: instance
     
- target_label: __address__
        replacement
: 127.0.0.1:9116  # The SNMP exporter's real hostname:port.
    metric_relabel_configs
:
     
- source_labels: [__name__]
        regex
: '(FiberRxPower)([1-2])'
        replacement
: $2
        target_label
: PortIndex
     
- target_label: __name__
        replacement
: FiberRxPower





It works, and i think it's the most transparent way to do this.

However. Can you explain me how to do this with PromQL?


понедельник, 2 марта 2020 г., 14:08:54 UTC+12 пользователь Виталий Ковалев написал:
Hello.

Виталий Ковалев

unread,
Mar 5, 2020, 6:17:05 PM3/5/20
to Prometheus Users
Some fix for previous message.

# Scrape rules for Planar TUZ19-2003
 
- job_name: planar_tuz19_2003
    metrics_path
: /snmp
    params:
      module: [planar_tuz19_2003]
    file_sd_configs:
        - files :
          - /
etc/prometheus/devices/optical_receivers/planar_tuz19_2003.yml
          refresh_interval
: 2m

    relabel_configs
:
     
- source_labels: [__address__]
        target_label
: __param_target
     
- source_labels: [__param_target]
        target_label
: instance
     
- target_label:
__address__
        replacement
: 192.168.168.168:9116  # The SNMP exporter's real hostname:port.

    metric_relabel_configs
:
     
- source_labels: [__name__]
        regex
: '(FiberRxPower)([1-2])'
        replacement
: $2
        target_label
: PortIndex
     
- source_labels: [__name__]
        regex
: '(FiberRxPower)([1-2])'

        target_label
: __name__






понедельник, 2 марта 2020 г., 14:08:54 UTC+12 пользователь Виталий Ковалев написал:
Hello.

Виталий Ковалев

unread,
Mar 5, 2020, 6:25:43 PM3/5/20
to Prometheus Users
I am a little confused.
This article talks that it's better to improve your instrumentation than use relabeling.

And can you tell about, how i can do this with PromQL?

среда, 4 марта 2020 г., 9:25:51 UTC+12 пользователь Ben Kochie написал:
There's no function because it's intended for PromQL to deal with these issues. Metrics exporters are designed to provide the data as raw as possible to avoid second guessing the underlying data.

On Tue, Mar 3, 2020 at 10:05 PM Виталий Ковалев <kvp9...@gmail.com> wrote:
FiberRxPower is just name for the metic.
It's very sad that there is'nt such functional in snmp_exporter.
Maybe i should open a featureRequest on github?
However, thanks for help.

понедельник, 2 марта 2020 г., 14:08:54 UTC+12 пользователь Виталий Ковалев написал:
Hello.
On  my network i have some specific devices(Optical Receivers), which violate usual snmp rules.
For example - When you do snmpwalk on IF-MIB::IfSpeed OID you get many values in this format:
IF-MIB::ifSpeed.X = Gauge32: 10000000
Where X Number of Interface.

My devices have other logic. They have several oids for one metric(for example optical signal power on inputs(total inputs-2)):
OPTICAL_INPUT1: 1.3.6.1.4.1.32108.1.9.2.2.0
OPTICAL_INPUT2: 1.3.6.1.4.1.32108.1.9.2.3.0

How i can write it in one metric with several label for port? I want output something like this:
FiberRxPower{portIndex="1"} -999
FiberRxPower{portIndex="2"} -36

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages