Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

custom bash script to configure ambari alerts from UI

Highlighted

custom bash script to configure ambari alerts from UI

New Contributor

Hello,


Is there any way to create a custom script in bash to retrieve or get the custom alerts(Critical etc) from Ambari UI?

2 REPLIES 2

Re: custom bash script to configure ambari alerts from UI

Super Mentor

@Nani Bigdata

Using Ambari API calls you can get the alerts based on the alert state (like CRITICAL, WARNING ...etc)


You can write that login inside the Shell Script as it can be triggered using simple curl commands and then parse the JSON data based on your convenient.


For example based on the CRITICAL Or WARNING state you can capture all the alerts that are triggered as following (where component/host are not in maintenance mode):

# curl -k -H "X-Requested-By: ambari" -u admin:admin -X GET "http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/alerts?fields=Alert/component_name,Alert/definition_id,Alert/definition_name,Alert/host_name,Alert/id,Alert/instance,Alert/label,Alert/latest_timestamp,Alert/maintenance_state,Alert/original_timestamp,Alert/scope,Alert/service_name,Alert/state,Alert/text,Alert/repeat_tolerance,Alert/repeat_tolerance_remaining&Alert/state.in(CRITICAL,WARNING)&Alert/maintenance_state.in(OFF)"


In the above API call you will need to replace the following:

$AMBARI_HOST:8080 = Your Ambari Server FQDN/Hostname and Port

$CLUSTER_NAME = Your cluster name

admin:admin = with your Ambari Admin credentials.

.

Re: custom bash script to configure ambari alerts from UI

Super Mentor

@Nani Bigdata

Does it answers your query? Or do you have any additional query in this regard?
If not then please mark this HCC thread as resolved by clicking on the "Accept" Button.