17 May 2023 12:25 PM - last edited on 17 May 2023 03:16 PM by MaciejNeumann
Hi,
I am trying to update the anomaly detection setting using 'settings' API but wondering what are the scopes or level on which I can update it.
Question 1: Can I update it on HOST_GROUP or PROCESS_GROUP or SERVICE level?
Question 2: Where to find the api documentation for request body?
Solved! Go to Solution.
17 May 2023 01:09 PM
Hi @Naveen,
it will be based on the type of anomaly detection and you can check the available schemas including anomaly and related scope to apply it such as host, host group, environment, ... etc.
now after getting the required schema Id, it's time to post it as an object
and there is an easy approach you can use, you can go to the anomaly detection settings, whether on a certain service, host group, or globally and copy the API and adjust it
in the below example, I'm using Anomaly detection for databases on a certain DB, and by changing the scope from service to environment it will be adjusted globally, (Note: I've removed the id of the service, you can add your service id, change the scope based on your requirements and remove the space between "requests PerMinute")
builtin:anomaly-detection.databases
The scope will be one of the following:
SERVICE_METHOD - Request
SERVICE - Service
HOST_GROUP - Host Group
environment
Token scope: settings.write
[
{"schemaId":"builtin:anomaly-detection.databases",
"scope":"SERVICE-",
"value":
{
"responseTime":
{
"enabled":true,
"detectionMode":"auto",
"autoDetection":
{
"responseTimeAll":
{
"degradationMilliseconds":500,
"degradationPercent":1000
},
"responseTimeSlowest":
{
"slowestDegradationMilliseconds":200,
"slowestDegradationPercent":1000
},
"overAlertingProtection":
{
"requests PerMinute":100,
"minutesAbnormalState":2
}
}
},
"failureRate":
{
"enabled":true,
"detectionMode":"auto",
"autoDetection":
{
"absoluteIncrease":0,
"relativeIncrease":50,
"overAlertingProtection":
{
"requests PerMinute":10,
"minutesAbnormalState":1
}
}
},
"loadDrops":
{
"enabled":false
},
"loadSpikes":
{
"enabled":false
},
"databaseConnections":
{
"enabled":true,
"maxFailedConnects":100,
"timePeriod":10
}
}
}
]
also, you can use API v1 as well but I think the recommendation is to use API v2 such as Settings API
https://www.dynatrace.com/support/help/dynatrace-api/configuration-api/anomaly-detection-api
18 May 2023 05:49 AM
Thanks is it possible to update it on process group level so that it can apply to all the services underneath. I can understand we can update it on host group and this will apply to all the hosts and services under that.
18 May 2023 09:46 AM
Hi @Naveen,
it will not be applied on a process group level, also, based on which anomaly detection the scope is different, for instance, for service anomaly detection, it will be applied on the environment level (Globally), Host Group level, Service, Requests, as for Application anomaly detection, it will be applied on the environment level (Globally), Application, User Action.
so it's the same as you configure the anomaly detection using UI, so process group is not an option