Start with regex: '(.*)'

If that works, then you know it's just the regex at fault. I'd start by 
trying to double-backslash, i.e.

- regex: '([\\w]{2}:[\\w]{2}:[\\w]{2}:[\\w]{2}:[\\w]{2}:[\\w]{2})'

The spec for Go's regex language (RE2) is 
here: https://github.com/google/re2/wiki/syntax

I'm not sure if a backslash character class is allowed inside a 
square-bracket character class. So you could try:

- regex: '((\\w){2}:(\\w){2}:(\\w){2}:(\\w){2}:(\\w){2}:(\\w){2})'
- regex: 
'([[:alnum:]]{2}:[[:alnum:]]{2}:[[:alnum:]]{2}:[[:alnum:]]{2}:[[:alnum:]]{2}:[[:alnum:]]{2})'

or something simpler like:

- regex: '([a-fA-F0-9:]{17})'

On Tuesday, 4 March 2025 at 22:11:04 UTC Matthew Koch wrote:

> I'm trying to extract the MAC address out of what is returned by SNMP 
> exporter. The Regex I am using seems to work in general when I used an 
> online Regex tester but for some reason it's not working in SNMP exporter.
>
> SNMPExporter config:
>
>     - name: apSysStatBssid
>       oid: 1.3.6.1.4.1.11.2.14.11.6.4.5.1.1.1.1.31.3
>       type: PhysAddress48
>       help: MAC address of the AP that the HPE501 is Associated to. - 
> 1.3.6.1.4.1.11.2.14.11.6.4.5.1.1.1.1.31.3
>       regex_extracts:
>         Test: 
>           - regex: '([\w]{2}:[\w]{2}:[\w]{2}:[\w]{2}:[\w]{2}:[\w]{2})' 
>             value: '$1'
>
> This is what I typically get data wise without the regex config:
>
> # HELP apSysStatBssid BSSID of currently connected accesspoint - 
> 1.3.6.1.4.1.29456.3.2
> # TYPE apSysStatBssid gauge
> apSysStatBssid{apSysStatBssid="6A:56:E3:7A:85:47"} 1

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/prometheus-users/5486bebd-db05-45e0-8049-88f18a2dbb31n%40googlegroups.com.

Reply via email to