# Use of placeholder for automatically applied tags (host names)

**URL:** <https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880>\
**Category:** Open Q&A\
**Tags:** tagging, hosts-classic\
**Created:** [January 9, 2020, 3:13pm UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880 "2020-01-09T15:13:33Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![urs\_fischer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/urs_fischer/32/7896_2.png) [@urs\_fischer](https://community.dynatrace.com/u/urs_fischer)\
**Post date:** [January 9, 2020, 3:13pm UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/1 "2020-01-09T15:13:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dave\_mauney](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dave_mauney/32/27784_2.png) [@dave\_mauney](https://community.dynatrace.com/u/dave_mauney)\
**Post date:** [January 9, 2020, 5:27pm UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/2 "2020-01-09T17:27:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![justin\_hogue](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/justin_hogue/32/19679_2.png) [@justin\_hogue](https://community.dynatrace.com/u/justin_hogue)\
**Post date:** [January 9, 2020, 5:35pm UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/3 "2020-01-09T17:35:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![urs\_fischer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/urs_fischer/32/7896_2.png) [@urs\_fischer](https://community.dynatrace.com/u/urs_fischer)\
**Post date:** [January 10, 2020, 9:52am UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/4 "2020-01-10T09:52:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ctturner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ctturner/32/11883_2.png) [@ctturner](https://community.dynatrace.com/u/ctturner)\
**Post date:** [January 10, 2020, 1:14pm UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/5 "2020-01-10T13:14:56Z")

</div>

[@Urs F.](https://answers.dynatrace.com/users/34599/view.html) 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](https://regex101.com/)

 ![23140-regex.png](https://global.discourse-cdn.com/dynatrace/original/1X/b4fa37e02e74518cfe0393c4cb0bee90bbd420e7.png)

---

<div class="post-metadata">

**Author:** ![sundarv1](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sundarv1](https://community.dynatrace.com/u/sundarv1)\
**Post date:** [June 4, 2024, 4:44am UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/6 "2024-06-04T04:44:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paulo\_calaxa](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@paulo\_calaxa](https://community.dynatrace.com/u/paulo_calaxa)\
**Post date:** [June 4, 2024, 6:49am UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/7 "2024-06-04T06:49:45Z")

</div>

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](https://global.discourse-cdn.com/dynatrace/original/2X/2/28efd178d946fc6767261f45743d27fe05d1e260.png)

normal characters? substitute the “d” for&nbsp; a “w”  
Any character? substitute the “\d” for a “.”  
You may test it in&nbsp;[https://regex101.com/](https://regex101.com/)  
and it also as examples/help, at the lower right corner  
&nbsp;  
Kind regards,  
Paulo

---

<div class="post-metadata">

**Author:** ![sundarv1](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sundarv1](https://community.dynatrace.com/u/sundarv1)\
**Post date:** [June 9, 2024, 7:56am UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/8 "2024-06-09T07:56:50Z")

</div>

Hi URU

Please share screenshot of how you have done this in automatic applied tags?.&nbsp; Please find my screenshot . i am still finding where to add to rule for to match hostname condition.  
[hostname.docx](https://community.dynatrace.com/uploads/short-url/18GJ0KqtYCvxcXRwQ3obqlbYsFw.docx) (39.1 KB)

---

<div class="post-metadata">

**Author:** ![sundarv1](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sundarv1](https://community.dynatrace.com/u/sundarv1)\
**Post date:** [June 9, 2024, 8:11am UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/9 "2024-06-09T08:11:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sundarv1](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sundarv1](https://community.dynatrace.com/u/sundarv1)\
**Post date:** [June 9, 2024, 8:27am UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/10 "2024-06-09T08:27:14Z")

</div>

This is the issue., Since there is hostname is matching - what we do if 10th of hostname is 5 or 3.

Windows name -&nbsp;auszvrcuw346.rcuad.local

Unix name -&nbsp;auszvrcuw346

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [June 9, 2024, 3:02pm UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/11 "2024-06-09T15:02:20Z")

</div>

Same question answered [here](https://community.dynatrace.com/post/247772).

---

<div class="post-metadata">

**Author:** ![sundarv1](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sundarv1](https://community.dynatrace.com/u/sundarv1)\
**Post date:** [October 15, 2024, 3:45am UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/12 "2024-10-15T03:45:58Z")

</div>

Hi Paulo

above solution worked for&nbsp;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

---

<div class="post-metadata">

**Author:** ![sundarv1](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sundarv1](https://community.dynatrace.com/u/sundarv1)\
**Post date:** [October 15, 2024, 3:57am UTC](https://community.dynatrace.com/t/use-of-placeholder-for-automatically-applied-tags-host-names/22880/13 "2024-10-15T03:57:47Z")

</div>

please find the attached one.&nbsp; when i put the and condition to have hostname start with auu - it is not giving actual result

 ![auu.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/c/dc945b174671bdbf7f8de182a5fe2105daf03360.png)
