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

Is there any API to POST Process Group Monitoring Rule?

nakb
Guide

Hi I am trying to automate the Process Group Monitoring Rule in Dynatrace but I am unable to find any POST API for this, please let me know if any available or any other way to automate it.

 

naveen_0-1619599365306.png

9 REPLIES 9

pahofmann
DynaMight Guru
DynaMight Guru

Unfortunately there is no API for this yet. You can vote for my RFE here.

 

Dynatrace Certified Master - Dynatrace Partner - 360Performance.net

MaciejNeumann
Community Team
Community Team

As @pahofmann and @mark_bley are mentioning in the related Product Idea, this is now possible through Settings API.

pahofmann_0-1643187417266.png

You can try following payload and send it to "/api/v2/settings/objects"

 

[
    {
        "schemaVersion": "1.0.7",
        "schemaId": "builtin:declarativegrouping",
        "scope": "environment",
        "value": {
            "enabled": true,
            "name": "MY TEST",
            "detection": [
                {
                    "id": "MY TEST",
                    "processGroupName": "Some PG Name",
                    "rules": [
                        {
                            "property": "executablePath",
                            "condition": "$eq(/path/to/exec)"
                        }
                    ]
                }
            ]
        }
    }
]
If you have any questions about the Community, you can contact me at maciej.neumann@dynatrace.com

nakb
Guide

Hi @MaciejNeumann,

 

I have tried the above API and it's not working. I am getting 400 error. Also documentation is not clear.

 

Could you please check.

A 400 (Bad Request) means somthing is wrong with the payload  you are trying to send.

It should also list a message with the problem (e.g. which part of the json could not be parsed).

Dynatrace Certified Master - Dynatrace Partner - 360Performance.net

nakb
Guide

Hi @pahofmann,

 

I used exact same payload as above also tried from the API documentation it's not working.

 

Also documentation is not clear like what are the valid schema id's

 

https://www.dynatrace.com/support/help/dynatrace-api/environment-api/settings/objects/post-object#de...

I'd be easier if you could post the output from your request. It should list what is wrong.

 

You can get the schema id's either from the UI as mentioned above or from the dedicated endpoint for it. 

Dynatrace Certified Master - Dynatrace Partner - 360Performance.net

nakb
Guide

Hi @pahofmann,

 

Payload:

 

[{
    "schemaId": "builtin:process.custom-process-monitoring-rule",
    "scope": "environment",
    "value":{
        "autoMonitoring": true
    }
}]

 

 

I am getting below error:

 

[
    {
      "code": 400,
      "error": {
        "code": 400,
        "message": "Validation failed for 4 Validators.",
        "constraintViolations": [
          {
            "path": "builtin:process.custom-process-monitoring-rule/0/mode",
            "message": "Given property 'mode' with value: 'null' does not comply with required NonNull of schema",
            "parameterLocation": "PAYLOAD_BODY",
            "location": null
          },
          {
            "path": "builtin:process.custom-process-monitoring-rule/0/condition",
            "message": "Given property 'condition' with value: 'null' does not comply with required NonNull of schema",
            "parameterLocation": "PAYLOAD_BODY",
            "location": null
          },
          {
            "path": "builtin:process.custom-process-monitoring-rule/0/autoMonitoring",
            "message": "Given property 'autoMonitoring' with value: 'true' was not found in the schema",
            "parameterLocation": "PAYLOAD_BODY",
            "location": null
          },
          {
            "path": "builtin:process.custom-process-monitoring-rule/0/enabled",
            "message": "Given property 'enabled' with value: 'null' does not comply with required NonNull of schema",
            "parameterLocation": "PAYLOAD_BODY",
            "location": null
          }
        ]
      },
      "invalidValue": {
        "autoMonitoring": true
      }
    }
  ]

 

 
On API page SettingsValue navigation not working, unable to check what are the valid parameters.
 
naveen_0-1654607280369.png

 

Well it lists all the values that must be present that you are missing.

 

You can check the schema via /settings​/schemas​/{schemaId} to to see all the fields.

 

Or you can just create a setting in the GUI and then list all the objects from the schema via /settings/objects to check what it should look like.

Dynatrace Certified Master - Dynatrace Partner - 360Performance.net

Naveen
Guide

Hi @pahofmann,

 

Thanks I am able to create custom process monitoring rule.

 

Below is the example payload used.

[
    {
        "schemaId": "builtin:process.custom-process-monitoring-rule",
        "scope": "environment",
        "value": {
            "enabled": true,
            "mode": "MONITORING_ON",
            "condition": {
                "item": "IIS_APP_POOL",
                "operator": "STARTS",
                "value": "Demo"
            }
        }
    }
]

 

Featured Posts