27 Feb 2025
10:24 AM
- last edited on
27 Feb 2025
01:44 PM
by
MaciejNeumann
Good morning.
We've got to SaaS Dynatrace environment.
In the Dev one I've created a set of automatic tag rules I'm happy with and I would like to know if there is a easy way to get that set of rules from that teenant and moved it into the Prod teenant.
Maybe using the API can be a solution.
I've managed to get the list of automatic tag rules by running:
curl -X GET "https://{environmentid}.live.dynatrace.com/api/v2/settings/objects?schemaIds=builtin%3Atags.auto-tag..." -H "Authorization: Api-Token my.token" -H "Content-Type: application/json" | jq .
Any idea.
Thank you all in advance!
Solved! Go to Solution.
27 Feb 2025 11:19 AM
HI @CarlosTF
You can use Monaco or the Terraform provided - which ever you prefer to manage this.
I'll go with Monaco as you'll get a little more support from Dynatrace on this since it's their preferred tool.
Documentation is here: Dynatrace Configuration as Code — Dynatrace Docs
Example (inc. Auto Tag): Deploy your first configuration — Dynatrace Docs
Git Repo: GitHub - Dynatrace/dynatrace-configuration-as-code: This tool automates deployment of Dynatrace Conf...
I would recommend first taking a backup via monaco cli, which will give you all your configs (inc auto tags) in a format that you can then use going forward. e.g create a new repo and only copy across what you need to automate.
Anyway, have fun
27 Feb 2025 12:26 PM
Thank you very much gopher, I'll give it a try
28 Feb 2025 02:03 PM
We use Monaco for pushing and pulling configurations from one tenant to another. However you need to be careful with scoping because there's a lot of ID use and ID's are tenant specific. We're moving to the Terraform provider to help with some of this translation.
27 Feb 2025 12:53 PM
As @gopher indicates, the preferred option for Dynatrace is to use Monaco, but I find that in most cases doing it via API is much faster and more direct. Especially for transferring configurations from one environment to another. I find Monaco ideal for having a backup of the configuration.
27 Feb 2025 01:10 PM
The terraform provider is also a great tool for this scenario
you can export the resource
https://docs.dynatrace.com/docs/deliver/configuration-as-code/terraform/guides/export-utility
dynatrace_autotag_v2
And load it to the new tenant.
https://docs.dynatrace.com/docs/deliver/configuration-as-code/terraform/guides/migration
27 Feb 2025 01:54 PM
If you are looking to Pull Rules that are defined in a particular Tenant, Ive found that it is easy to just run an API export using the GET and then jumping over to your target Tenant and pasting it as a POST. Yes you will need to delete a few segments like the TAG ID as that ID is associated to the GET request and the new POST will generate its own ID.
Now with the recent designs, you wont be able to use the old tag API, youll need to use the "Settings - Objects" from the Envrionment V2. If you need the schema ID, you can go to the Auto tags and click the "..." in the upper right hand and select Schema Info:
You can also then select the Auto Tag and click the "..." you can then see the API just for that Tag segment as well:
Then just paste in the Schema ID, pull the export, then shift to the post.
If you are looking to Pull Rules that are defined in a particular Tenant, Ive found that it is easy to just run an API export using the GET and then jumping over to your target Tenant and pasting it as a POST. Yes you will need to delete a few segments like the TAG ID as that ID is associated to the GET request and the new POST will generate its own ID.
Now with the recent designs, you wont be able to use the old tag API, youll need to use the "Settings - Objects" from the Envrionment V2. If you need the schema ID, you can go to the Auto tags and click the "..." in the upper right hand and select Schema Info:
You can also then select the Auto Tag and click the "..." you can then see the API just for that Tag segment as well:
Then just paste in the Schema ID, pull the export, then shift to the post.
28 Feb 2025 01:43 PM
What a positive surprised seing so many people trying to help.
I appreciate all your answer a lot. Thank you all 🙂
Right now we are backing up the Prd teenant so probably we wont tackle this until next Monday.
Anyway, the Terraform seemed the most suitable way until @ChadTurner explained how to use the API.
It took me some tries to make it work but I could export the tag rules object and create a new tag with a similar name to check how to do it and it worked great. So I think that, being confortable with the howto, using the API is going to be my choice once the backup is done.
I'll keep you reported.
Thank you all again and have a great WK
28 Feb 2025 01:50 PM
There are many ways that you can achieve the desired outcome, just what best fits your needs and skill sets. You could then even move towards a script to do it all for you! I'm thrilled with all the responses and options we all provided you, a true 'community' effort for sure!
04 Mar 2025 11:10 AM
After getting a backup in the Prod teenant first, I ended finally using the API as @ChadTurner suggested to do the export and it work perfectly well. No issues at all.
Thank you very much everybody for al the suggested approches which I would like one day to explore those other aprroches/capabilities.
Thank you all again!!
11 Mar 2025 09:18 AM
Documentation is here: Dynatrace Configuration as Code — Dynatrace Docs
i have attached a word Doc file it will guide you step by step regarding how you can achieve it
12 Mar 2025 09:01 AM
Thank you very much @Abidyaseen , I'll take a look to that too 🙂