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

Use of placeholder for automatically applied tags (host names)

urs_fischer
Guide

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.


4 REPLIES 4

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