Created 06-10-2019 04:13 AM
Hello,
Is there any way to create a custom script in bash to retrieve or get the custom alerts(Critical etc) from Ambari UI?
Created 06-10-2019 05:45 AM
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.
.
Created 06-26-2019 02:02 PM
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.
Created on 11-16-2020 09:24 AM - edited 11-16-2020 09:25 AM
@jsensharma Getting error while running this query given by You.