Best practices for SNMP string values

654 views
Skip to first unread message

Elliott Balsley

unread,
Aug 16, 2023, 1:06:34 AM8/16/23
to Prometheus Users
As I'm evaluating Prometheus for SNMP monitoring, it seems like it's not well suited for tracking string values.  Is that correct, or can anyone share how it's working for them?
As an example, I'm monitoring a Dolby CP850 and one of the metrics is returned like this:

cp850BitstreamFormat{cp850BitstreamFormat="dolbyAtmos"} 1

There are 8 possible string values for that one.  This OID type is OctetString, and I am overriding to be DisplayString.  So this becomes 8 separate time series, which is very hard to graph appropriately.  My goal is to track this (among other similar metrics) on a State Timeline in grafana, where the key on the Y axis is "Bitstream Format" and the values shows "dolbyAtmos", "pcm", "dolbyDigital", etc.

I appreciate any ideas!

Ben Kochie

unread,
Aug 16, 2023, 2:14:34 AM8/16/23
to Elliott Balsley, Prometheus Users
Prometheus is perfectly suited for these string values. The semi-static boolean 0/1 values compress very well, making it very efficient to store in the TSDB.

There are three ways to handle this in the snmp_exporter. Default DisplayString as you have it, EnumAsInfo, and EnumAsStateSet.

EnumAsInfo is useful for strings that you don't expect to change often / at all.

EnumAsStateSet is useful for metrics where you are expecting the state to change. I'm guessing for your use case you want to use this one.

Once you have this, you will get 8 series, but they will have a 0 or 1 for which the ENUM is set. Then you can graph 'cp850BitstreamFormat == 1' to view which is active.

It would help if you posted a link to the MIB, as it would help to understand 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/CALajkdjJ_raGUTtfTmg9RGtBAWAcHuYoNz7CMm%3DfWuhBbEFocQ%40mail.gmail.com.

Elliott Balsley

unread,
Aug 16, 2023, 12:45:57 PM8/16/23
to Ben Kochie, Prometheus Users
Thanks, I'll try this.  I hadn't thought of graphing with the ==1 piece.
However, when I try this as EnumAsStateSet, it always has a value of 0 like this:
cp850BitstreamFormat{cp850BitstreamFormat="0"} 1

I think this is because the OID is defined as OctetString, so I first need to decode the hex to ASCII and then turn it into enum.  Is this possible?
An example from snmpwalk:
$ snmpwalk -v2c -c public -m DOLBY-CP850-MIB 10.49.51.30 1.3.6.1.4.1.6729.2.1.1.1.3.2.4 -Ox
DOLBY-CP850-MIB::cp850BitstreamFormat.0 = Hex-STRING: 70 63 6D

The mib is called DOLBY-CP850-MIB.  I've attached it here with its dependencies.
DOLBY_CP850_MIB_FILES.zip

Elliott Balsley

unread,
Aug 16, 2023, 1:06:58 PM8/16/23
to Ben Kochie, Prometheus Users
As a related question, how would you handle this if the string values can change to any arbitrary value, i.e. not a state set?  Example:
qsysDesignName{qsysDesignName="Roma v1.9 v9.5.0_W EQ"} 1

I have this set as a DisplayString, so my Grafana time series range query is qsysDesignName{site="$site", room="$room"} .  Then I have to use labels-to-fields, followed by organize-fields transformations to get the state timeline look correct.  If there are more than 1 metric in the state timeline then I also need an outer join or merge.  This works but it feels hacky.
image.png
qscAudio_qsys.mib
Reply all
Reply to author
Forward
0 new messages