cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating a metric event via APIv2: "No scope generator registered"

CJimenez
Visitor

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 

 

[
    {
        "schemaId""builtin:anomaly-detection.metric-events",
        "value": {
            "enabled"true,
xxxxxxxxx
 
---RESPONSE
        "error": {
            "code"404,
            "message""No scope generator registered for schema builtin:anomaly-detection.metric-events"
        },
 
I'm only guessing, but does that mean there is currently no implementation of the metric-event scope within the settings API v2?
3 REPLIES 3

rgarzon1
Pro

HI cjimenez

 

maybe its something else. i just try the schema and works 

 

rgarzon1_0-1668277068365.png

 

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

 

fuelled by coffee and curiosity.

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"
}
}
]

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.

Featured Posts