regexwildcardwildcard-subdomain

Domain Regex for Prometheuse


I am trying to write a regex that will ignore the first two octets 'name.name-name.presto.worker' but will match the rest which is 'presto.worker'.

I have two different domain names that follow the same structure like I shown above and I need the monitoring system to catch both domains using the two last octects presto.worker.

My last regex that I have found that almost work is:

count(up{instance="/[A-Za-z.]+[A-Za-z.-]+(presto.)+(worker)/g"})

It's for Prometheuse monitoring system. Thanks for the help Yaniv


Solution

  • I have found the answer for that and thanks for directing me. for prometheus to treat a code as a regex we need to inset ~ at the beginning make the code like that:

    count(up{instance=~"[A-Za-z.]+[A-Za-z.-]+(presto.)+(worker)"}) BY (presto_failuredetector_HeartbeatFailureDetector_ActiveCount) < 0.90

    Notice the ~ after instance=