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

Automatic tags - variable fields

Bartlomiej
Frequent Guest

Hi everyone!

I have a big problem with automated tags. We are offering dynatrace to our customers. To distinguish servers we are using few custom tags. Each monitored server has around 8 tags like working hours, customer email, customer name etc etc. I need to have this tags on each entity to receive proper mail notification. Now I need to add tags manually, but its a pain and I'm looking for some automations. Do you have any ideas how to improve this process?
Thanks!

6 REPLIES 6

AntonPineiro
DynaMight Guru
DynaMight Guru

Hi,

I would suggest you reading Best practices and recommendations for tagging.

A combination of automatic tags + host metadata might be useful to your usecase.

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

PedroSantos
Advisor

Hey @Bartlomiej !

Might be worth looking into the Settings>Tags>Automatically applied tags menu and see if there's any metadata on your servers you can use to automatically apply tags across them. There's a fair chance you'll be able to apply tags automatically from here, but I can't tell for sure given I'm unfamiliar with your environment.

 

Alternatively, Dynatrace does have a Custom Tags API which you might be able to leverage in order to get this task done with some sort of custom script that uses this API. As with most if not all API use cases, I highly recommend making use of the Dynatrace API Support Resource (Swagger) to ensure you have the syntax properly done:

PedroSantos_0-1735811801171.png

On the new interface, you can do Ctrl+K to search and find the Swagger here:

PedroSantos_1-1735811879096.png

The Custom Tags API is part of the Environment API v2, so choose that:

PedroSantos_3-1735812105535.png

On the old interface you can click the person icon on the upper right corner and find it here:

PedroSantos_2-1735811984285.png

And inside you'll have this:

PedroSantos_4-1735812158789.png

 

Of course, you'll need a valid Access Token to use the API, but this isn't difficult to do assuming you have the necessary permissions.

 

Let me know if this helps you 🙂

 

To make an error is human. To spread the error across all servers in an automated way is DevOps.

Bartlomiej
Frequent Guest

Unfortunately metadata doesn't contain anything I could use. Basically we are getting a table from customer with his information, contract number so we could say all data is outside.
I'm not very familiar with API - do you think is it possible to have one script as a template which will be using external file to fetch data?
I'm trying to find a best way to automate as much I can for other colleagues.


Yeah, it's definitely possible to have some sort of script that looks into a csv table and automates the tagging through API calls. I like to use Python for this.

You fetch the data from the table, save it to variables and make the API call based on these variables. Now do this on a cycle to make repeated calls with different variables and you're tagging the different servers.

It does require a bit of technical python scripting knowledge, but it should be doable.

I also emphasize you should definitely read the link that Anton posted if you're going to automate tagging on a large scale.

To make an error is human. To spread the error across all servers in an automated way is DevOps.

Hi,

Yes, you can use API as @PedroSantos is saying.

And ingest your custom host metadata using oneagentctl, if OneAgent is installed.

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

ChadTurner
DynaMight Legend
DynaMight Legend

as @AntonPineiro stated. Host Meta data is going to the your holy grail. What we did was extract core data from our CMDB. Application ID, Application Name, Ownership, Cost Center, Environment etc.... Then we formulated an automatic tag that looks at that one construct, take Cost center for example. We defined a single auto tag rule called "Cost Center" then provided the variable Value on the Key:Value pair for tags, so as a new cost center was added into the CMDB and therefore ingested into Dynatrace, It populated that value as a tag because it was also ingested as custom meta data on the host. This then allowed for filtering, sorting etc. 

-Chad

Featured Posts