Automatically applied tags API - POST an auto-tag
Creates a new automatically applied tag.
The request consumes and produces an application/json
payload.
POST | Managed | https://{your-domain}/e/{your-environment-id}/api/config/v1/autoTags |
SaaS | https://{your-environment-id}.live.dynatrace.com/api/config/v1/autoTags | |
Environment ActiveGate | https://{your-activegate-domain}/e/{your-environment-id}/api/config/v1/autoTags |
Authentication
To execute this request, you need an access token with Write configuration (WriteConfig
) scope. To learn how to obtain and use it, see Tokens and authentication.
Parameters
Refer to JSON models to find all JSON models that depend on the type of the model.
Parameter | Type | Description | In | Required |
---|---|---|---|---|
body | Auto | The JSON body of the request. Contains parameters of the new auto-tag. | body | optional |
Request body objects
The AutoTag
object
Configuration of an auto-tag. It defines the conditions of tag usage and the tag value.
Element | Type | Description |
---|---|---|
metadata | Configuration | Metadata useful for debugging Can be |
id | string | The ID of the auto-tag. Can be |
name | string | The name of the auto-tag, which is applied to entities. Additionally you can specify a valueFormat in the tag rule. In that case the tag is used in the For example you can extend the |
description | string | The description of the auto-tag. Can be |
rules | Auto | The list of rules for tag usage. When there are multiple rules, the OR logic applies. Can be |
entitySelectorBasedRules | Entity | A list of entity-selector based rules for auto tagging usage. If several rules are specified, the OR logic applies. Can be |
The ConfigurationMetadata
object
Metadata useful for debugging
Element | Type | Description |
---|---|---|
configurationVersions | integer[] | A sorted list of the version numbers of the configuration. Can be |
currentConfigurationVersions | string[] | A sorted list of version numbers of the configuration. Can be |
clusterVersion | string | Dynatrace version. Can be |
The AutoTagRule
object
A rule for the auto-tag.
Defines the conditions of tag usage.
Element | Type | Description |
---|---|---|
type | string | Type of entities to which the rule applies. |
enabled | boolean | Tag rule is enabled ( |
valueFormat | string | The value of the auto-tag. If specified, the tag is used in the For example, you can extend the You can use the following placeholders here:
Can be |
normalization | string | Changes applied to the value after applying the value format. Default is LEAVE_TEXT_AS_IS. Can be |
propagationTypes | string[] | How to apply the tag to underlying entities:
Can be |
conditions | Entity | A list of matching rules for the auto-tag. The tag applies only when all conditions are fulfilled. |
The EntityRuleEngineCondition
object
A condition defines how to execute matching logic for an entity.
Element | Type | Description |
---|---|---|
key | Condition | The key to identify the data we're matching. The actual set of fields and possible values depend on the type of the key. Find the list of actual objects in the description of the type field or see JSON models. |
comparisonInfo | Comparison | Defines how the matching is actually performed: what and how are we comparing. The actual set of fields and possible values of the operator field depend on the type of the comparison. Find the list of actual objects in the description of the type field or see JSON models. |
The ConditionKey
object
The key to identify the data we're matching.
The actual set of fields and possible values depend on the type of the key. Find the list of actual objects in the description of the type field or see JSON models.
Element | Type | Description |
---|---|---|
attribute | string | The attribute to be used for comparison. |
type | string | Defines the actual set of fields depending on the value. See one of the following objects:
Can be |
The ComparisonBasic
object
Defines how the matching is actually performed: what and how are we comparing.
The actual set of fields and possible values of the operator field depend on the type of the comparison. Find the list of actual objects in the description of the type field or see JSON models.
Element | Type | Description |
---|---|---|
operator | string | Operator of the comparison. You can reverse it by setting negate to Possible values depend on the type of the comparison. Find the list of actual models in the description of the type field and check the description of the model you need. |
value | object | The value to compare to. Can be |
negate | boolean | Reverses the comparison operator. For example it turns the begins with into does not begin with. |
type | string | Defines the actual set of fields depending on the value. See one of the following objects:
|
The EntitySelectorBasedAutoTagRule
object
The entity-selector-based rule for auto tag usage. It allows tagging entities via an entity selector.
Element | Type | Description |
---|---|---|
enabled | boolean | The rule is enabled ( Can be |
entitySelector | string | The entity selector string, by which the entities are selected. |
valueFormat | string | The value of the entity-selector-based auto-tag. If specified, the tag is used in the For example, you can extend the Can be |
normalization | string | Changes applied to the value after applying the value format. Default is LEAVE_TEXT_AS_IS. Can be |
Request body JSON model
This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request.
{
"name": "sampleAutoTag",
"description": "sampleDescription",
"rules": [
{
"type": "SERVICE",
"enabled": true,
"valueFormat": "myTagValue {Service:DetectedName}",
"propagationTypes": [
"SERVICE_TO_HOST_LIKE"
],
"conditions": [
{
"key": {
"attribute": "SERVICE_DATABASE_NAME"
},
"comparisonInfo": {
"type": "STRING",
"operator": "BEGINS_WITH",
"value": "sample",
"negate": false,
"caseSensitive": false
}
},
{
"key": {
"attribute": "SERVICE_WEB_SERVER_NAME"
},
"comparisonInfo": {
"type": "STRING",
"operator": "EXISTS",
"negate": false
}
},
{
"key": {
"attribute": "PROCESS_GROUP_CUSTOM_METADATA",
"type": "PROCESS_CUSTOM_METADATA_KEY",
"dynamicKey": {
"source": "KUBERNETES",
"key": "kubernetes.io/limit-ranger"
}
},
"comparisonInfo": {
"type": "STRING",
"operator": "BEGINS_WITH",
"value": "sample",
"negate": false,
"caseSensitive": false
}
}
]
}
],
"entitySelectorBasedRules": [
{
"enabled": true,
"entitySelector": "type(HOST) AND cpuCores(4)"
}
]
}
Response
Response codes
Code | Type | Description |
---|---|---|
201 | Entity | Success. The auto-tag has been created. The response body contains the ID of the new auto-tag. |
400 | Error | Failed. The input is invalid. |
Response body objects
The EntityShortRepresentation
object
The short representation of a Dynatrace entity.
Element | Type | Description |
---|---|---|
id | string | The ID of the Dynatrace entity. |
name | string | The name of the Dynatrace entity. Can be |
description | string | A short description of the Dynatrace entity. Can be |
Response body JSON model
{
"id": "6a98d7bc-abb9-44f8-ae6a-73e68e71812a",
"name": "Dynatrace entity",
"description": "Dynatrace entity for the REST API example"
}
Validate payload
We recommend that you validate the payload before submitting it with an actual request. A response code of 204 indicates a valid payload.
The request consumes an application/json
payload.
POST | Managed | https://{your-domain}/e/{your-environment-id}/api/config/v1/autoTags/validator |
SaaS | https://{your-environment-id}.live.dynatrace.com/api/config/v1/autoTags/validator | |
Environment ActiveGate | https://{your-activegate-domain}/e/{your-environment-id}/api/config/v1/autoTags/validator |
Authentication
To execute this request, you need an access token with Write configuration (WriteConfig
) scope. To learn how to obtain and use it, see Tokens and authentication.
Response
Response codes
Code | Type | Description |
---|---|---|
204 | - | Validated. The submitted configuration is valid. Response doesn't have a body. |
400 | Error | Failed. The input is invalid. |
Example
In this example, the request creates a new auto-tag for Services where the service name contains main
. The services and hosts they're running on were assigned the MainApp tag.
The API token is passed in the Authorization header.
The request body is lengthy, so it is truncated in the Curl section. See the Request body section for the full body. You can download or copy the example request body to try it out on your own.
Curl
curl -X POST \
https://mySampleEnv.live.dynatrace.com/api/config/v1/autoTags \
-H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890' \
-H 'Content-Type: application/json' \
-d '{ <truncated - see the Request body section > }'
Request URL
https://mySampleEnv.live.dynatrace.com/api/config/v1/autoTags
Request body
{
"name": "MainApp",
"rules": [
{
"type": "SERVICE",
"enabled": true,
"valueFormat": null,
"propagationTypes": ["SERVICE_TO_HOST_LIKE"],
"conditions": [
{
"key": {
"attribute": "SERVICE_NAME"
},
"comparisonInfo": {
"type": "STRING",
"operator": "CONTAINS",
"value": "main",
"negate": false,
"caseSensitive": false
}
}
]
}
]
}
Response body
{
"id": "e3f5bfc1-ead4-4af8-9372-48beb05e03f9",
"name": "MainApp"
}
Response code
201
Result
The new auto-tag looks like this in the UI: