11 Nov 2022 04:33 PM - last edited on 27 Mar 2023 08:15 AM by MaciejNeumann
Hi,
I have been using the settings API v2 to create anomaly detection for process availability alerts.
I am now trying to apply the same process to create metric event alerts (formerly known and custom events for alerting).
However, I get an error when trying to post to the settings API
https://xxxxx.live.dynatrace.com/e/xxxxx/api/v2/settings/objects?validateOnly=true
Solved! Go to Solution.
12 Nov 2022 06:19 PM - edited 12 Nov 2022 06:20 PM
HI cjimenez
maybe its something else. i just try the schema and works
maybe the version of the manage ui ? idk i am guessing..
im using SaaS: dynatrace version 1.254.92.20221109-192319
hope it helps
have fun
15 Nov 2022 08:41 AM - last edited on 27 Mar 2023 08:16 AM by MaciejNeumann
Hi,
Thanks for your response, yes, I get the same when I query the API but does not accept a POST
This works fine:
GET https://{your-domain}.live.dynatrace.com/e/{your-domain}/api/v2/settings/objects?schemaIds=builtin:anomaly-detection.metric-events
However, this returns the error "No scope generator registered for schema builtin:anomaly-detection.metric-events":
POST https://{your-domain} .live.dynatrace.com/e/{your-domain} /api/v2/settings/objects?validateOnly=true
With JSON payload:
[
{
"schemaId": "builtin:anomaly-detection.metric-events",
"schemaVersion": "1.0.1",
"value": {
"enabled": true,
"summary": "TEST METRIC EVENT",
"queryDefinition": {
"type": "METRIC_KEY",
"metricKey": "builtin:host.disk.usedPct",
"aggregation": "MAX",
"entityFilter": {
"dimensionKey": "dt.entity.host",
"conditions": [
{
"type": "TAG",
"operator": "EQUALS",
"value": "TEST_TAG"
}
]
},
"dimensionFilter": []
},
"modelProperties": {
"type": "STATIC_THRESHOLD",
"threshold": 80.0,
"alertOnNoData": false,
"alertCondition": "ABOVE",
"violatingSamples": 3,
"samples": 5,
"dealertingSamples": 5
},
"eventTemplate": {
"title": "TEST METRIC EVENT",
"description": "Testing API creation of metric event",
"eventType": "RESOURCE",
"davisMerge": true,
"metadata": []
},
"eventEntityDimensionKey": "dt.entity.host"
}
}
]
23 Nov 2022 06:18 PM
Found the issue for those facing similar:
The issue was the missing scope. For other settings that relate to an entity, you need to provide the entity ID as the scope. But in the case of Metric Events, the scope needs to be 'environment' as it does not link to a specific entity.