My orgainzation is using AWS Fargate, and we're seeing the host information being named after the task definition. I'm trying to create an auto tag that gets the name of the host name (task definition) and tags the instance with the first part of the host name. For example all my hosts that come in look like this:
How can I grab the name of the prefix "LearningDynamics" and tag that as ProductTeam: LearningDynamics? And how would i grap suffix "JumpingStars" and tag that as ProductApplication: JumpingStars?
Solved! Go to Solution.
simply go to settings > tags > Automatically applied tags
add new one with JumpingStars , set rule applied to "HOSTS" then add condition with property `Detected host name` and choose begins with `LearningDynamics` and save, also see the figure mentioned below
A more dynamic way to do this is by using regular expressions and capture groups in your automatic tag definition to capture only the part of the value (in this case, LearningDynamics or Jumping Stars) from the parameter you're using (in this case, I assume host detected name). The hardest part here is to work with regex, as Dynatrace has some limitations when using it. The way to use it is to set the attribute you're going to use as the value of the tag, and follow it with a forward slash (/) and the regular expression used to extract the actual value you want to use.
For example, if you want to capture just the JumpingStars part of your host name, as per your example, an automatic tag configuration that would work is the following:
Where you capture anything character (except for ;) after the first whitespace is found.
Make sure to check out the link above to know what you can and can't do with regex and apply that to the rest of your use case.