TL;DR: How can I use a parameter in a regex?
$param$\d.example.com does not work. Adding 1 or 2 backslashes does not work either
I need to set up a BI Aggregation for some clustered services. The setup looks like this:
Three-ish servers, which have numbered hostnames
and a Loadbalancer with the same name, but no number.
We use this naming-schema for multiple services (LDAP, WEB, …) and I wanted to create rules with parameters. The aggregation is a very flat tree:
Service $service="email"$ is available (Worst status of all children)
|--> Loadbalancer $service="email"$ (Worst)
|--> Cluster nodes $service="email"$\d (Worst, but limited to WARNING)
So I tried to set up a rule and set the
Child Node Generator to
Create Nodes based on a host search to capture the numbered cluster-hosts but it wants a regex, which seems to be incompatible with
$parameters$ due to the dollar sign.
Is that correct or is there a trick to use parameters in regexes?
I was unable to find any reference and surfing the cmk code is too hard for me.
edit: add screenshot
have you tried to create parameters for SERVICE and NUMBER?
Then the regex should look like: $SERVICE$$NUMBER$.example.com
somethin like this works also: $MYPARAM$[0-9].example.com
Karl, Christian, thanks for the answers!
Alas, even with them I don’t get this to work. I documented the whole setup in this poster.
I hope it goes through in full resolution. Otherwise I’ll think of something and edit this post.
I just wonder how a dollar-sign, which means “end-of-line” in regular expressions, can be used here without some magic.
Did you try $HOSTNAME$ or $1$ for the Host itself form search result. This is what described in the Help of the Rule.
Aha. Thank you Christian. That put me on the right track.
I’ve been playing around and seen some funny things.
So these are my experiment-notes. First line is the
Hostname Regex, second line is
Nodes to create and third line is the result. To start my fun result without a parameter:
* "all hosts"
= 156 (!) nodes, 52x email1-3 - one for each of the 52 hostnames in the database.
* .* (which is effectively "all hosts")
= 3 correct nodes
-> "all hosts" is not the same as "regex .*"
Now with the parameter. I’ll start with the correct answer and then add all my failures.
= Perfect result. but why?
= 1 correct host. seems like it kind of matters where the parens go.
= 1 correct host. number one: email1.example.de - 2 missing
Now for some other fun: The same thing, but for services!
So far, I’ve been able to produce hosts with “Create nodes based on a service search”:
Create Nodes based on a service search
+ regex for host name
+ nodes to create host - empty is not allowed
service regex is empty with the non-parameterized rules.
non-parameterized rules have "regex for host name" and "nodes to create host" the same value
= added 3 host nodes. not a single service.
= 52 different host entries. each server in the database.
Any idea what is going on here?
I would like to prefer to call a rule to detect the needed services for the host from host serach. If you want more than one service you can use a pipe like “CPU.*|Memory.*” and so on.
I give up. I cannot get it to work and so I have decided to create all my (honestly few) rules manually.
Thank you for all your time.