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

Can I use API to realize Put Metric events setting?


Click the API on the page of Metric events, and the system gives the method of obtaining page data by default, but if I want to realize new Metric events through API, can it be realized? Because put/settings/objects/{objectid} in API V2.
Updates an existing settings object and POST /settings/objects Creates a new settings object didn't make it clear.


DynaMight Legend
DynaMight Legend

I'm not 100% of the true ask of this question but If you are looking to Post new Custom Events for alerting, It can be done via the Environment V2 > Settings - Objects, From there you will use builtin:anomaly-detection.metric-events as the Schema ID and then get the ID of the item you want. Thake that ID and get the settings of that object ID, edit and report it as needed or even create a net new set up via the Posting option. 




Dynatrace Champion
Dynatrace Champion

Creating a new metric event through the API can be achieved like follow:

(This is just a curl example with some dummy payload, you would need to adjust fields to your needs)

curl --location --request POST 'https://{environmentid}' \
--header 'accept: application/json; charset=utf-8' \
--header 'Authorization: Api-Token dt0c01.5VXCARPRP52BZNJVBUDSMQA5....' \
--header 'Content-Type: application/json; charset=utf-8' \
--data-raw '[
  "scope": "environment",
  "schemaId": "builtin:anomaly-detection.metric-events",
    "value": {
    "enabled": false,
    "summary": "DEMO ALERT",
    "queryDefinition": {
      "type": "METRIC_KEY",
      "metricKey": "builtin:host.cpu.usage",
      "aggregation": "AVG",
      "entityFilter": {
        "conditions": []
      "dimensionFilter": []
    "modelProperties": {
      "type": "STATIC_THRESHOLD",
      "threshold": 1,
      "alertOnNoData": false,
      "alertCondition": "ABOVE",
      "violatingSamples": 1,
      "samples": 3,
      "dealertingSamples": 3
    "eventTemplate": {
      "title": "DEMO TITLE",
      "description": "The {metricname} value of {severity} was {alert_condition} your custom threshold of {threshold}.",
      "eventType": "RESOURCE",
      "davisMerge": true,
      "metadata": []
    "eventEntityDimensionKey": ""

 The response on successful creation looks like this:

        "code": 200,
        "objectId": "vu9U3hXa3q0AAAABACdidWlsdGluOmFub21hbHktZGV0ZWN0aW9uLm1ldHJpYy1ldmVudHMABnRlbmFudAAGdGVuYW50ACRiN2JhOTU2Zi0xNTMwLTNiZTQtYWNiYS0zMjc5YThjODk3ZmG-71TeFdrerQ"

Featured Posts