I’m using the discovery.relabel component on kubernetes service targets from the discovery.kubernetes component, in order to filter targets to only the services which have a particular annotation. These annotations contain the URL path for blackbox health checks. This part is working fine.
I then want to filter the service targets by a given port (given in another service annotation), so that I’m only left with the services whose ports match the port in the annotation.
I’m trying to create a discovery.relabel rule to do this. I created the regex shown below for this purpose. It’s designed to check the two port numbers are equal, and write ‘true’ to a new label.
I’ve attempted to put this regex into a relabel rule but can’t get it to work, see below (note that I have removed the ^
/$
from the start/end for testing).
For the reference to the capture group in the regex
arg, I’ve tried using \1
, \\1
, $1
and ${1}
, but cannot get anything to work here. It may simply be that this regex engine doesn’t support using capture groups within the same expression.
Can anyone help with this? Have I just done something wrong? Or are there any alternatives to do what I want to do here?
Below are some of the targets where I would like to make sure the service port is equal to the blackbox port.
Thanks