cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use of placeholder for automatically applied tags (host names)

urs_fischer
Helper

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.

 

10 REPLIES 10

dave_mauney
Dynatrace Champion
Dynatrace Champion

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.


justin_hogue
Dynatrace Advisor
Dynatrace Advisor

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.


Thanks for your help. It looks like i have to read more about regex 🙂


@Urs F. Use this Regex link to test out Regex code. I used this when I was learning Regex to ensure the code was defined correctly.

Regex101


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

 

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

paulo_calaxa_0-1717483762054.png

 


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

when is use this [3|5]\d{2}$, i am getting only the names whose lastletter is 5, not 3.

 

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

sundarv1
Organizer

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.

Same question answered here.

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

Featured Posts