Custom tags API - GET tags
Lists all custom tags assigned to the specified monitored entities. Automatically applied tags and imported tags are not included.
The request produces an application/json
payload.
GET | ManagedDynatrace for Government | https://{your-domain}/e/{your-environment-id}/api/v2/tags |
SaaS | https://{your-environment-id}.live.dynatrace.com/api/v2/tags | |
Environment and Cluster ActiveGate (default port 9999) | https://{your-activegate-domain}:9999/e/{your-environment-id}/api/v2/tags |
Authentication
To execute this request, you need an access token with entities.read
scope.
To learn how to obtain and use it, see Tokens and authentication.
Parameters
Parameter | Type | Description | In | Required |
---|---|---|---|---|
entitySelector | string | Specifies the entities where you want to read tags. You must set one of these criteria:
You can add one or more of the following criteria. Values are case-sensitive and the
For more information, see Entity selector in Dynatrace Documentation. To set several criteria, separate them with a comma ( The maximum string length is 2,000 characters. | query | required |
from | string | The start of the requested timeframe. You can use one of the following formats:
If not set, the relative timeframe of 24 hours is used ( | query | optional |
to | string | The end of the requested timeframe. You can use one of the following formats:
If not set, the current timestamp is used. | query | optional |
Response
Response codes
Code | Type | Description |
---|---|---|
200 | CustomEntityTags | Success |
Response body objects
The CustomEntityTags
object
A list of custom tags.
Element | Type | Description |
---|---|---|
tags | METag[] | A list of custom tags. |
totalCount | integer | The total number of tags in the response. |
The METag
object
The tag of a monitored entity.
Element | Type | Description |
---|---|---|
context | string | The origin of the tag, such as AWS or Cloud Foundry. Custom tags use the |
key | string | The key of the tag. |
stringRepresentation | string | The string representation of the tag. |
value | string | The value of the tag. |
Response body JSON model
1{2 "tags": [3 {4 "context": "CONTEXTLESS",5 "key": "mainApp",6 "stringRepresentation": "mainApp"7 },8 {9 "context": "CONTEXTLESS",10 "key": "bookings",11 "stringRepresentation": "bookings"12 }13 ],14 "totalCount": 215}
Example
In this example, the request lists custom tags that are applied to services that belong to the management zones with the ID of 229130632296508575249. To achieve that, the entitySelector query parameter is set to type("SERVICE"),mzId("9130632296508575249")
.
The API token is passed in the Authorization header.
Because the full result is rather lengthy, it is truncated to three entries.
Curl
1curl -L -X GET 'https://mySampleEnv.live.dynatrace.com/api/v2/tags?entitySelector=type(%22SERVICE%22),mzId(%229130632296508575249%22)' \2-H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890'
Request URL
1https://mySampleEnv.live.dynatrace.com/api/v2/tags?entitySelector=type(%22SERVICE%22),mzId(%229130632296508575249%22)
Response body
1{2 "totalCount": 31,3 "tags": [4 {5 "context": "CONTEXTLESS",6 "key": "Billing",7 "stringRepresentation": "Billing"8 },9 {10 "context": "CONTEXTLESS",11 "key": "Booking",12 "stringRepresentation": "Booking"13 },14 {15 "context": "CONTEXTLESS",16 "key": "easytravel",17 "value": "backend",18 "stringRepresentation": "easytravel:backend"19 }20 ]21}
Response code
200