Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Ambari Alert REST API to filter out services on maintenance mode

avatar
Expert Contributor

we are using Ambari alerts Rest API to poll for components health. We would like to filter out the ones which are in Maintenance mode. Any idea what how we can get that. The REST API call throws all the services that are critical- http://<ambari host>:8080/api/v1/clusters/tech_hdp/alerts?Alert/state=CRITICAL

1 ACCEPTED SOLUTION

avatar
Expert Contributor

Given your initial request that you had, you can expand the fields which are returned by adding

fields=*

This will add a new field called "maintenance_state". So then we have the request

/api/v1/clusters/tech_hdp/alerts?fields=*&Alert/state=CRITICAL

From here we can filter out the ones with a maintenance state of ON, (returning only those with maintenance mode off)

/api/v1/clusters/tech_hdp/alerts?fields=*&Alert/state=CRITICAL&Alert/maintenance_state=OFF

I found this info on the API reference https://github.com/apache/ambari/blob/trunk/ambari...

View solution in original post

2 REPLIES 2

avatar
Expert Contributor

Given your initial request that you had, you can expand the fields which are returned by adding

fields=*

This will add a new field called "maintenance_state". So then we have the request

/api/v1/clusters/tech_hdp/alerts?fields=*&Alert/state=CRITICAL

From here we can filter out the ones with a maintenance state of ON, (returning only those with maintenance mode off)

/api/v1/clusters/tech_hdp/alerts?fields=*&Alert/state=CRITICAL&Alert/maintenance_state=OFF

I found this info on the API reference https://github.com/apache/ambari/blob/trunk/ambari...

avatar
Expert Contributor

Thank you very much @zblanco. It worked perfectly fine. Also thank you very much for the reference API.