Automatically applied tags API - PUT an auto-tag
Updates the specified automatically applied tag.
The request consumes and produces an application/json
payload.
PUT | ManagedDynatrace for Government | https://{your-domain}/e/{your-environment-id}/api/config/v1/autoTags/{id} |
SaaS | https://{your-environment-id}.live.dynatrace.com/api/config/v1/autoTags/{id} | |
Environment ActiveGate | https://{your-activegate-domain}/e/{your-environment-id}/api/config/v1/autoTags/{id} |
Authentication
To execute this request, you need an access token with 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 |
---|---|---|---|---|
id | string | The ID of the auto-tag to be updated. If you set the ID in the body as well, it must match this ID. | path | required |
body | Auto | The JSON body of the request. Contains updated parameters of the 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 | Required |
---|---|---|---|
metadata | Configuration | Metadata useful for debugging | optional |
id | string | The ID of the auto-tag. | optional |
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 | required |
description | string | The description of the auto-tag. | optional |
rules | Auto | The list of rules for tag usage. When there are multiple rules, the OR logic applies. | optional |
entitySelectorBasedRules | Entity | A list of entity-selector based rules for auto tagging usage. If several rules are specified, the OR logic applies. | optional |
The ConfigurationMetadata
object
Metadata useful for debugging
Element | Type | Description | Required |
---|---|---|---|
configurationVersions | integer[] | A sorted list of the version numbers of the configuration. | optional |
currentConfigurationVersions | string[] | A sorted list of version numbers of the configuration. | optional |
clusterVersion | string | Dynatrace version. | optional |
The AutoTagRule
object
A rule for the auto-tag.
Defines the conditions of tag usage.
Element | Type | Description | Required |
---|---|---|---|
type | string | Type of entities to which the rule applies. | required |
enabled | boolean | Tag rule is enabled ( | required |
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:
| optional |
normalization | string | Changes applied to the value after applying the value format. Default is LEAVE_TEXT_AS_IS. | optional |
propagationTypes | string[] | How to apply the tag to underlying entities:
| optional |
conditions | Entity | A list of matching rules for the auto-tag. The tag applies only when all conditions are fulfilled. | required |
The EntityRuleEngineCondition
object
A condition defines how to execute matching logic for an entity.
Element | Type | Description | Required |
---|---|---|---|
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. | required |
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. | required |
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 | Required |
---|---|---|---|
attribute | string | The attribute to be used for comparison. | required |
type | string | Defines the actual set of fields depending on the value. See one of the following objects:
| optional |
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 | Required |
---|---|---|---|
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. | required |
value | object | The value to compare to. | optional |
negate | boolean | Reverses the comparison operator. For example it turns the begins with into does not begin with. | required |
type | string | Defines the actual set of fields depending on the value. See one of the following objects:
| required |
The EntitySelectorBasedAutoTagRule
object
The entity-selector-based rule for auto tag usage. It allows tagging entities via an entity selector.
Element | Type | Description | Required |
---|---|---|---|
enabled | boolean | The rule is enabled ( | optional |
entitySelector | string | The entity selector string, by which the entities are selected. | required |
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 | optional |
normalization | string | Changes applied to the value after applying the value format. Default is LEAVE_TEXT_AS_IS. | optional |
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 new auto-tag has been created. The response body contains the ID of the new auto-tag. |
204 | Success. The auto-tag has been updated. Response doesn't have a body. | |
400 | ErrorEnvelope | 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. |
description | string | A short description of the Dynatrace entity. |
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 | ManagedDynatrace for Government | https://{your-domain}/e/{your-environment-id}/api/config/v1/autoTags/{id}/validator |
SaaS | https://{your-environment-id}.live.dynatrace.com/api/config/v1/autoTags/{id}/validator | |
Environment ActiveGate | https://{your-activegate-domain}/e/{your-environment-id}/api/config/v1/autoTags/{id}/validator |
Authentication
To execute this request, you need an access token with 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 | ErrorEnvelope | Failed. The input is invalid. |
Example
In this example, the request updates the Infrastructure - Linux auto-tag from the GET request example.
The initial configuration is the following:
The request adds an extra condition to the existing rule for the prod tag value, additionally requiring host group name to contain production
.
It also adds a new rule that assigns the preProd tag value for Linux hosts with names beginning with PreProd.
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 PUT \
https://mySampleEnv.live.dynatrace.com/api/config/v1/autoTags/7c82c170-b380-4fa7-992a-453f3e73047b \
-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/7c82c170-b380-4fa7-992a-453f3e73047b
Request body
{
"name": "Infrastructure - Linux",
"rules": [
{
"type": "HOST",
"enabled": true,
"valueFormat": "prod",
"propagationTypes": [],
"conditions": [
{
"key": {
"attribute": "HOST_OS_TYPE"
},
"comparisonInfo": {
"type": "OS_TYPE",
"operator": "EQUALS",
"value": "LINUX",
"negate": false
}
},
{
"key": {
"attribute": "HOST_NAME"
},
"comparisonInfo": {
"type": "STRING",
"operator": "BEGINS_WITH",
"value": "PreProd",
"negate": true,
"caseSensitive": true
}
},
{
"key": {
"attribute": "HOST_GROUP_NAME"
},
"comparisonInfo": {
"type": "STRING",
"operator": "CONTAINS",
"value": "production",
"negate": false,
"caseSensitive": true
}
}
]
},
{
"type": "HOST",
"enabled": true,
"valueFormat": "preProd",
"propagationTypes": [],
"conditions": [
{
"key": {
"attribute": "HOST_OS_TYPE"
},
"comparisonInfo": {
"type": "OS_TYPE",
"operator": "EQUALS",
"value": "LINUX",
"negate": false
}
},
{
"key": {
"attribute": "HOST_NAME"
},
"comparisonInfo": {
"type": "STRING",
"operator": "BEGINS_WITH",
"value": "PreProd",
"negate": false,
"caseSensitive": true
}
}
]
}
]
}
Response code
204
Result
The updated auto-tag has the following parameters: