2

I have two label as follows:

sysDescr="Cisco NX-OS(tm) nxos.7.0.3.I7.9.bin, Software (nxos), Version 7.0(3)I7(9), RELEASE SOFTWARE Copyright (c) 2002-2020 by Cisco Systems, Inc. Compiled 8/27/2020 4:00:00"
sysDescr="Cisco IOS Software, IOS-XE Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 03.06.06.E RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2016 by Cisco Systems, Inc. Compiled Sat 17-Dec"

What I want to do is creating a new label called software by matching string in sysDescr with the following label_replace function

label_replace(metric which includes sysDescr, "software", "$1", "sysDescr", "Cisco (IOS|NX-OS).*")

While this works for first one (NX-OS), it doesn't work for (IOS). I changed relabel regex to "(.*)" to see if my regex is wrong, this results nothing as well for second one.

What is the problem here?

  • have you tried with `(.+)` or `.+` as it is posted on this answer https://stackoverflow.com/a/54236687/2096986 ? – Felipe Sep 17 '21 at 11:50
  • still same. I also tried to relabel in prometheus.yml instead of replacing on the fly, it still doesn't work for label values starting with Cisco IOS.*. – Peder Zickler Sep 17 '21 at 12:08
  • that is very weird. I [pasted your regex here](https://regex101.com/r/ixDty9/1) and it is working completely fine ¯\_(ツ)_/¯ – Felipe Sep 17 '21 at 12:12
  • 1
    Try adding regex flag `s` to allow `.` character to match newlines `(?s:Cisco (IOS|NX-OS).*)` – PSSGCSim Sep 02 '22 at 11:21

0 Answers0