Search code examples
regexprometheuspromql

Regex for printing in between values


I have a total of 30 hosts whose hostnames follow this pattern: hostname-1.local to hostname-30.local

Printing the up status for all of them is easy: up{instance=~"hostname-[0-9]?[0-9].local"})

However, I want to list the up status only for hosts between hostname-5.local to hostname-12.local.

How do I do that?


Solution

  • Just split the logic into two alternatives: single digit numbers (5 to 9), and double-digit numbers (10 to 12):

    up{instance=~"hostname-([5-9]|1[0-2]).local"})