I have some tagging needs and based on some deployment/provisioning processes I want to implement tagging based on a simple Host Group pattern. I have 3 tags I want to define:
Environment can have 4 designations:
Application can have any number of designations:
Role can have 3 designations:
When installing the OneAgent, my provisioning team will be instructed to supply a Host Group name. For example:
In this example, I define 3 tags based on this pattern:
I am currently trying to build out the first part, but I found out you cannot use specific regex methods (probably for performance reasons) inside Dynatrace. Typically I would use:
To identify "np" as the environment however apparently you cannot use capturing and instead you have to use atomic groups. Can anyone make a suggestion on how to move forward?
Interesting, I tried the following to identify what I classify as "environment" (Part1):
I got an error that says: "Greedy or lazy character classes are not allowed, please use a possessive quantifier instead."
I get no error when I save it.
My host groups don't fit the pattern so I cannot easily test it, but I copied from a customer I used it on, basically...so I think it should work and it works fine on regex101.com when I test it as:
You have three groups, so maybe try these:
The question marks make it non-greedy, so the last one should work and be more efficient, I think.
I think this must be a user issue (my side obviously). So in the "Optional Tag Value" section I am putting in the following:
And then in the Conditions section I have:
Host Group Name contains regex ([^_]+?)_[^_]+
I then get
"Greedy or lazy character classes are not allowed, please use a possessive quantifier instead."
For reference, my current host groups are defined by 2 pieces of meta-data separated by an underscore. Examples are currently:
My biggest issue is that I am having a difficult time understanding the "optional tag value" and the function that the "conditions" section carries out.
I am using "Host Group Name" and "contains regex" and then trying to select the part in the "optional tag value" section that I want to target under conditions. I think I am misinterpreting something. There seems to be things you CAN do in the "Optional Tag Value" section that you CANNOT do in the "Conditions" section.
The optional tag value puts the value in the key/value pair of the tag. You can leave it out, but I always recommend key/value pairs over "flat" tags that consist of just a name. In this case, the regex tells it via the parentheses on the "group" to grab the first part of the Host Group before the first delimiter ("_").
The conditions part optionally filters the input. In this case saying to only include Host Groups that have a delimiter of "_". you cannot use the parentheses here as you cannot extract data in the condition.
Hey Dave M,
I wanted to thank you for your help on this. Here is what I had to do to get this to work for me (your guidance was crucial). The format of my host tags is as follows:
So below highlights the regex strings for each one:
For the condition, I just used "HostGroup" and "exists". I decided not to use a selection method in the condition section and just rely on the tag part.