The trouble with backslashes is that they have special meanings in all sorts of places - not only to regexs but also to the shell and to systemd - and working out how many times you have to double them up is very hard.
I suggest you simply replace \d with [0-9] and then life suddenly becomes much easier. I raised this before at https://github.com/prometheus/node_exporter/issues/1562 (see point 3). The actual regular expression contains \d. But this is shown in the Go source code as \\d because in a Go string, "\\" is a single backslash: ignoredDevices = kingpin.Flag("collector.diskstats.ignored-devices", "Regexp of devices to ignore for diskstats.").Default("^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\\d+n\\d+p)\\d+$").String() ./collector/systemd_linux.go: unitBlacklist = kingpin.Flag("collector.systemd.unit-blacklist", "Regexp of systemd units to blacklist. Units must both match whitelist and not match blacklist to be included.").Default(".+\\.(automount|device|mount|scope|slice)").String() And similarly, when kingpin (CLI library) displays the default value in its help output, the single backslash is doubled up: # /opt/node_exporter/node_exporter --help ... --collector.diskstats.ignored-devices="^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\\d+n\\d+p)\\d+$" --collector.systemd.unit-blacklist=".+\\.(automount|device|mount|scope|slice)" But depending on the context, e.g. if this is inside a systemd unit file or a shell script setting an environment variable, the doubling-up may have to be done multiple times. -- 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 on the web visit https://groups.google.com/d/msgid/prometheus-users/a1a6a1ff-8373-4f10-8a5b-1decf2916413%40googlegroups.com.

