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

Regex for Hostname

bill_scheuernst
DynaMight
DynaMight

I've been working on updating our automatic tag rules for a current project and would like to use Regex to capture a device type from a dns name, i.e. ABCCORE01.TEST.COM.  The ABC prefix is the location of the device, and CORE is the device type.  I would like to only use the device type as an optional tag value, such as "Device Capability: <value>".  I'm sure this is nothing new.

This worked in regex101, but not in DT...

^[a-zA-Z0-9]{0,3}([a-zA-Z]+?)\d

The location prefix can be ABC or AB1.

2 REPLIES 2

Mohamed_Hamdy
DynaMight Leader
DynaMight Leader

you can try this one, {Host:DetectedName/^AB[C0-9]([^.]*+).*$/$1/}

Certified Dynatrace Professional | Certified Dynatrace Services Delivery - Observability & CloudOps | Dynatrace Partner - yourcompass.ca

PacoPorro
Dynatrace Leader
Dynatrace Leader

Please check https://docs.dynatrace.com/docs/shortlink/regex

From my experience: pick the ungreedy option to test in regex101

PacoPorro_0-1758787049216.png 
with ^[A-Za-z0-9]{3}([A-Za-z]+?)\d+\.

PacoPorro_1-1758787191067.png

 

Featured Posts