I’d like to define a service discovery rule Disabled checks to disable mysql_capacity section of mk_mysql plugin on some of our database servers named:
maria-db1
maria-db2
maria-db3
What I did
As described in inline help, I added this to Explicit hosts in rule definition:
~maria-db
The condition is recognized as regex in rules list: Host name matches regex maria-db
But no success, the rule does not apply to any of above mentioned hosts.
I also tried these, but without success as well:
~maria-db.*
~maria-db.
To make sure rule definition works at all, I tried to define each host manually by adding each to explicit hosts, which worked as expected. Disabled Checks was listed in used host rules.
Question
How to use regex in explicit hosts correctly?
Does it work in CEE 2.1.0.p44 at all?
I tried with 2.1.0p38 cee and it works for me with just
~maria-db
Of course, I used a different hostname, but I just used the beginning of my actual hostnames. The above won’t work, if the hosts are called e.g. my-maria-db or something. In that case, use ~.*maria-db
Maybe your rule unintentionally has some other conditions? A folder, for example?
Thanks for your hint, but that doesn’t work either.
As expected, because inline help says so:
… The names that you enter here are compared with case sensitive exact matching. Alternatively you can use regular expressions if you enter a tilde (~) as the first character. That regular expression must match the beginning of the host names in question…
shot in the dark, but would you mind sharing screenshots of the rule + the Setup Menu and the hosts location + a view of the service in the host?
Maybe the issue is not with the regex but something else? (I guess we’ve all been there, looking at a problem for too long that one focuses on the wrong aspect)