non-regex label mapping

35 views
Skip to first unread message

Michael Thomas

unread,
Dec 18, 2020, 7:58:19 AM12/18/20
to Prometheus Users
I need to perform a large number (~120) of metric label remappings in my prometheus config.  Right now I'm doing it with 120 entries that look like these:

      - source_labels: [fcFeModuleName,fcFxPortIndex]
        target_label: portName
        regex: 0x100000C0DD18FE13;1
        replacement: DeviceName
      - source_labels: [fcFeModuleName,fcFxPortIndex]
        target_label: portName
        regex: 0x100000C0DD18FE13;2
        replacement: AnotherDeviceName

...repeated for many different combinations of fcFeModuleName and fcFxPortIndex.  The regex that I'm using doesn't have any RE patterns in it, so this mapping could be reduced to a simple non-regex map.  I was hoping I could do something a little more concise, like this:

      - source_labels: [fcFeModuleName,fcFxPortIndex]
        target_label: portName
        replacement_map:
          "0x100000C0DD18FE13;1": DeviceName
          "0x100000C0DD18FE13;2": AnotherDeviceName
          "0x100000C0DD18FE13;3": andYetAnother

Is something concise like this already possible, or should I file a RFE?

I do note that if I were scraping an ethernet switch, I could use portIndex+portName in my snmp_exporter to assign friendly names as labels automatically.  But my fiberchannel switch does not expose the friendly names via snmp, thus the need to do the friendly name label assignment individually in prometheus.

--Mike

Ben Kochie

unread,
Dec 18, 2020, 8:05:10 AM12/18/20
to Michael Thomas, Prometheus Users
Are you sure this isn't an issue with OctetString vs DIsplayString? Can you share your generator.yml?

--
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/fbbde3aa-7c48-4a2c-9998-ecb6827f01b3n%40googlegroups.com.

Michael Thomas

unread,
Dec 18, 2020, 8:18:54 AM12/18/20
to Prometheus Users
Here's my generator.yml:

# QLogic Fiberchannel switches
  fiberchannel:
    walk:
      - fcFxPortID
      - fcFxPortC3InFrames
      - fcFxPortC3OutFrames
      - fcFxPortC3Discards
      - fcFxPortLinkResetIns
      - fcFxPortLinkResetOuts
    lookups:
      - source_indexes: [fcFeModuleIndex]
        lookup: fcFeModuleName

I've done a full snmpwalk over the entire device, but didn't see anything in the output that resembled any of the friendly names I assigned in the switch config.

--Mike

Ben Kochie

unread,
Dec 18, 2020, 8:26:23 AM12/18/20
to Michael Thomas, Prometheus Users
Yes, it looks like fcFeModuleName is a TEXTUAL-CONVENTION for the Worldwide Name. Which isn't exactly a friendly name.

To be honest, I don't think there's going to be a lot of interest in changing the regexp matching behavior. You could write a proposal to prometheus...@googlegroups.com, but unless you're willing to write/sponsor writing the code, it's not going to get much attention.

If there's another API on the Brocade devices (json/rest API?) that could provide the data, it might be worth making a custom exporter. Otherwise, you might ask Brocade support why the labels are not exposed.

Reply all
Reply to author
Forward
0 new messages