09 Jan 2020 03:13 PM - last edited on 28 Sep 2022 10:41 AM by MaciejNeumann
I have a problem with automatically applied tags. I guess it's a simple question, and yet I can't figure it out. We have a special name convention for our server names. The second digit of the host name means the stage in which the server is located (production, pre-procurement, etc.). Is it possible to create an automatically applied tag rule based on the hostname, depending on the value of the second digit of the host?
Example hostname: S45002134A (second character "4" means pre-production)
To create the rule:
- Rule applies to: "hosts"
- Condition: "Hostname" "begins with" (or "contains")
What needs to be entered in the field? I need kind of a placeholder for the first digit because the it changes based on other conditions.
Solved! Go to Solution.
09 Jan 2020 05:27 PM
I would try "contains regex" with ".4" as your condition. You can set the "optional tag value" to "pre-production" for this example and replicate the rule for other environments.
09 Jan 2020 05:35 PM
Rule applies to: "hosts"
Condition: "Host name" "contains regex"
Value: ^.{1}[4]
This might also work. It should match the second character of a string depending on what is in the square brackets.
10 Jan 2020 09:52 AM
Thanks for your help. It looks like i have to read more about regex 🙂
04 Jun 2024 05:44 AM
Hi Justin
How to do tagging if 3rd last character of hostname in 3 or 5.,
auszvrcuw333 - how to do regex if 3rd last character of hostname in 3 or 5, tagging it as staging.
Thanks
Sundar.v
04 Jun 2024 07:49 AM - edited 04 Jun 2024 07:55 AM
Hi.
For instance, you may confirm that it accepts and works as intended:
[3|5]\d{2}$
given the following strings, it will only match the ones ending in digits, with 3 or 5 in the 3rd last place:
auszvrcuw33z
auszvrcuw333
auszvrcuw446
auszvrcuwa46
auszvrcuw3z3
auszvrcuw33a
auszvrcuw346
auszvrcuw546
normal characters? substitute the "d" for a "w"
Any character? substitute the "\d" for a "."
You may test it in https://regex101.com/
and it also as examples/help, at the lower right corner
Kind regards,
Paulo
09 Jun 2024 09:11 AM
when is use this [3|5]\d{2}$, i am getting only the names whose lastletter is 5, not 3.
09 Jun 2024 09:27 AM
This is the issue., Since there is hostname is matching - what we do if 10th of hostname is 5 or 3.
Windows name - auszvrcuw346.rcuad.local
Unix name - auszvrcuw346
15 Oct 2024 04:45 AM
Hi Paulo
above solution worked for ones ending in digits, with 3 or 5 in the 3rd last place.
How do i add one more condition so that it picks up when hostname starts with aus
15 Oct 2024 04:57 AM
please find the attached one. when i put the and condition to have hostname start with auu - it is not giving actual result
09 Jun 2024 08:56 AM
Hi URU
Please share screenshot of how you have done this in automatic applied tags?. Please find my screenshot . i am still finding where to add to rule for to match hostname condition.
09 Jun 2024 04:02 PM
Same question answered here.