Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
Labels (1)
avatar
Rising Star

First you need to get the ID of the alert definition in your system:

curl -H "X-Requested-By: ambari" -u admin:<password> -X GET http://<ambari_host>:<ambari_port>/api/v1/clusters/<cluster_name>/alert_definitions?AlertDefinition/...

Get the alert definition with the id from prevoius step:

curl -H "X-Requested-By: ambari" -u admin:<password> -X GET http://<ambari_host>:<ambari_port>/api/v1/clusters/<cluster_name>/alert_definitions/61

Set the new thresholds by changing the JSON alert definition:

curl -H "X-Requested-By: ambari" -u admin:<password> -i -X PUT -d '
{
   "AlertDefinition":{
      "cluster_name":"xyz",
      "component_name":"AMBARI_AGENT",
      "description":"This host-level alert is triggered if the amount of disk space used on a host goes above specific thresholds. The default values are 85% for WARNING and 90% for CRITICAL.",
      "enabled":true,
      "id":61,
      "ignore_host":false,
      "interval":1,
      "label":"Ambari Agent Disk Usage",
      "name":"ambari_agent_disk_usage",
      "scope":"HOST",
      "service_name":"AMBARI",
      "source":{
         "parameters":[
            {
               "name":"minimum.free.space",
               "display_name":"Minimum Free Space",
               "units":"bytes",
               "value":1.0E9,
               "description":"The overall amount of free disk space left before an alert is triggered.",
               "type":"NUMERIC",
               "threshold":"WARNING"
            },
            {
               "name":"percent.used.space.warning.threshold",
               "display_name":"Warning",
               "units":"%",
               "value":0.85,
               "description":"The percent of disk space consumed before a warning is triggered.",
               "type":"PERCENT",
               "threshold":"WARNING"
            },
            {
               "name":"percent.free.space.critical.threshold",
               "display_name":"Critical",
               "units":"%",
               "value":0.9,
               "description":"The percent of disk space consumed before a critical alert is triggered.",
               "type":"PERCENT",
               "threshold":"CRITICAL"
            }
         ],
         "path":"alert_disk_space.py",
         "type":"SCRIPT"
      }
   }
}' http://<ambari_host>:<ambari_port>/api/v1/clusters/<cluster_name>/alert_definitions/61

Ambari API Reference: https://github.com/apache/ambari/blob/trunk/ambari-server/docs/api/v1/index.md

3,669 Views
Comments
avatar
New Contributor

I found it easier to download the json to a file, edit it on disk, then use the `-d @filename.json` in the final step to avoid lengthy command lines. The only caveat: the "href" line needs to be deleted from the json obtained in step two.

Version history
Last update:
‎04-15-2016 01:26 PM
Updated by:
Contributors