Rule for label creation based on service name

Hi there,

I want to add a rule for label creation in checkmk which is based on the ending of a service name.
So as an example I want to add a label to a service whenever it ends in XYZ. Every combination I tried in wato’s main dashboard under Host & Service Parameters is not working. Whenever I save the rule, the condition keeps saying either

  • Service name begins with XYZ (including the sign I add, i.e. *XYZ or .*XYZ or ~.*XYZ)
  • Service name is XYZ (once I add a $ at the end of a rule)

I already looked into the official guides for regex and labels or wato rules.

Any ideas how to make the label based on a rule starting at the end / not starting at the beginning?

Thanks in advance!

Hi,
have you tried …

^.*XYZ$

?

Karl

2 Likes

I just tried this in a 1.6.0p17 Enterprise setup, works for me.

WATO → Host & Service Parameters → Monitoring Configuration → [Service Checks] Service labels

“[Conditions] Services”: .*/var$
(starting with any character any count. then literal “/”, “v”, “a”, “r”, then end of string)

This should match services like “Filesystem /var” and “Mount options of /var” but not “… /var/log”

The ruleset overview shows the condistions for this rule as “Service name is .*/var” (yes, including the regexp special characters dot and asterisk in the beginning, but not the trailing dollar sign)
And when I activate my changes, I get my “test:true” label added to the matching services as expected and to no other service.

2 Likes

Thanks for the quick replies. I was a bit confused by the wording “Service name is” and thought it would maybe change into “Service name ends with” similar to the existing “Service name begins with”.

I tried it out with .*XYZ and for service labels it works.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.