cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Narendra.Reddy
AppDynamics Team

How do I enable or disable Health Rules and policies using an API? Is there a way to delete Health Rules?

 

In this article...


 

APIs for enabling and disabling Health Rules and policies

The following REST API calls enable or disable Health Rules (HR) and policies

  • HR Disable

    Request type: DELETE
    URL: http://<controller-host>:<port>/controller/api/accounts/<account-id>/applications/<application-id>/healthrules/<healthrule-id>/enabled
    Response status: 204 No Content

 

  •  HR Enable

    Request type: PUT
    URL: http://<controller-host>:<port>/controller/api/accounts/<account-id>/applications/<application-id>/healthrules/<healthrule-id>/enabled
    Response status: 204 No Content

 

  • Policy Disable

    Request type: DELETE
    URL: http://<controller-host>:<port>/controller/api/accounts/<account-id>/applications/<application-id>/policies/<policy-id>/enabled
    Response status: 204 No Content

 

  • Policy Enable

    Request type: PUT
    URL: http://<controller-host>:<port>/controller/api/accounts/<account-id>/applications/<application-id>/policies/<policy-id>/enabled
    Response status: 204 No Content

 

  • Retrieve HRs and Policies

    Request Type: GET
    URLs: http://<controller-host>:<port>/controller/api/accounts/<account-id>/applications/<application-id>/healthrules
    http://<controller-host>:<port>/controller/api/accounts/<account-id>/applications/<application-id>/policies
    Response status: 200 Ok

 

How do I delete a Health Rule?

 You use this cURL command to delete Health Rules:

  1. Get the JESSIONID and X-CSRF-TOKEN for the user having login access to controller UI:
    curl -i --user admin@customer1:admin http://localhost:8090/controller/auth?action=login​
    
    HTTP/1.1 200 OK
    cache-control: no-cache, no-store, max-age=0, must-revalidate
    Pragma: no-cache
    Expires: Thu, 01 Jan 1970 00:00:00 GMT
    Set-Cookie: JSESSIONID=8edd9e48f2ec26cbeeb6f24126b5; Path=/controller; HttpOnly
    Set-Cookie: X-CSRF-TOKEN=46f1d4590d4955d55a1428e53b8d495fd57bdcd7
    Date: Fri, 28 Jul 2017 11:21:15 GMT
    Content-Length: 0

     

  2. Run the following CURL call with JESSIONID and X-CSRF-TOKEN from step 1, replacing Controller host, port and credentials, and Health_rule_ids as required.
    curl -X POST -H "Cookie:JSESSIONID=8edd9e48f2ec26cbeeb6f24126b5;" -H "X-CSRF-TOKEN:46f1d4590d4955d55a1428e53b8d495fd57bdcd7" -H "Content-Type: application/json" -H "Accept: application/json" http://osxltnredd.local:8090/controller/restui/health_rules/delete -d [Health_rule_ids]​

 

Related Links

You may find the following Documentation links useful:

Comments
Alex.Forkosh
Voyager

Is there a way to delete a health rule using API?

Narendra.Reddy
AppDynamics Team

We do not have out-of-the box support to delete the health rules.

 

However, here is the Here is a way to do delete health rules using cURL command:

  • Get the JESSIONID and X-CSRF-TOKEN for the user having login access to controller UI:
curl -i --user admin@customer1:admin http://localhost:8090/controller/auth?action=login

HTTP/1.1 200 OK
cache-control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: JSESSIONID=8edd9e48f2ec26cbeeb6f24126b5; Path=/controller; HttpOnly
Set-Cookie: X-CSRF-TOKEN=46f1d4590d4955d55a1428e53b8d495fd57bdcd7
Date: Fri, 28 Jul 2017 11:21:15 GMT
Content-Length: 0

  • Run the following CURL call with JESSIONID and X-CSRF-TOKEN from step 1?
curl -X POST -H "Cookie:JSESSIONID=8edd9e48f2ec26cbeeb6f24126b5;" -H "X-CSRF-TOKEN:46f1d4590d4955d55a1428e53b8d495fd57bdcd7" -H "Content-Type: application/json" -H "Accept: application/json" http://osxltnredd.local:8090/controller/restui/health_rules/delete -d [Health_rule_ids]


PS: replace controller host, port and credentials and Health_rule_ids as required.

Alex.Forkosh
Voyager

Perfect, works as described!

Does the "HR Disable" using delete  still work in the SaaS environments? I'm unable to get this working in Postman and not seeing this option referenced in the documentation. Is this still best practice ?

Claudia.Landivar
AppDynamics Team (Retired)

Hi, @Bill.Anderson - I'll work on tracking down a reply to your question... though resolution may be next week.

I opened a ticket  with support on this. They suggested this link

 

https://docs.appdynamics.com/21.11/en/extend-appdynamics/appdynamics-apis/alert-and-respond-api/heal...

Narendra.Reddy
AppDynamics Team

@Bill.Anderson These API's are still working. I have tested on one of our in-house latest controllers.

 

Version history
Last update:
‎06-09-2022 08:08 AM
Updated by:
June 26 Webinar
Discover new Splunk integrations and AI innovations for Cisco AppDynamics.


Register Now!

Observe and Explore
Dive into our Community Blog for the Latest Insights and Updates!


Read the blog here