How do I assign a tag to a monitored entity?

The Topology & Smartscape API not only offers REST endpoints for fetching information related to all the monitored components in your environment, it also allows you to assign tags to individual components.

By using the same REST endpoints as described above, it's possible to perform an HTTP POST call to push a list of tags to a given entity ID, as shown in the example below.

https://{id}.live.dynatrace.com/api/v1/entity/services/{YOUR_SERVICE_ID}

with HTTP POST payload:

{
  "tags": ["myTagthroughAPI", "secondTag"]
}

Notes:

  • You must change the entity endpoint designation from the above example if the entity is different than service. The /entity endpoint is related to what you want to tag. For example, use /entity/infrastructure/hosts to tag a Host entity, or use /entity/services to tag a Service entity.

  • You must add the content-type header field with the value application/json in the POST request, otherwise an error 415 "Unsupported/Missing 'Content-Type' header is returned.