02 Jan 2025 09:45 AM
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!
02 Jan 2025 10:00 AM
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
02 Jan 2025 10:03 AM
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:
On the new interface, you can do Ctrl+K to search and find the Swagger here:
The Custom Tags API is part of the Environment API v2, so choose that:
On the old interface you can click the person icon on the upper right corner and find it here:
And inside you'll have this:
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 🙂
02 Jan 2025 10:21 AM
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.
02 Jan 2025 10:51 AM
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.
02 Jan 2025 11:44 AM - edited 02 Jan 2025 11:44 AM
Hi,
Yes, you can use API as @PedroSantos is saying.
And ingest your custom host metadata using oneagentctl, if OneAgent is installed.
Best regards
02 Jan 2025 12:22 PM
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.