Creating Alarms Using REST API

Create an alarm definition in a JSON file and run the following POST command to create the new alarm.

$ curl -X POST -u domain:bruin -H "Accept: application/json" -H "Content-type: application/json" 
-d @json_filename http://localhost:8888/api/1/alarms/definitions

Creating Domain Event Alarms

JSON code for a domain event alarm looks as follows:

{
  "name": "Database Process Joined",
  "description": "A Process has joined the database ...",
  "eventType": "NodeJoined",
  "dimension": "Domain",
  "entityId": "",
  "severity": "Warning",
  "action": "NotifyEvent"
}

Create this alarm (assuming the file is called myevent.json and an Amazon EC2 instance) with the following command:

$ curl -X POST -u domain:bruin -H "Accept: application/json" -H "Content-type:application/json"
 -d @myevent.json http://ec2-54-165-58-157.compute-1.amazonaws.com:8888/api/1/alarms/definitions
{"name":"Database Process Joined","description":"A Process has joined the database...",
"severity":"Warning","action":"NotifyEvent","entityId":"","eventType":"NodeJoined",
"dimension":"Domain"}
$

Creating Statistical Alarms

JSON code for a statistical alarm (specifically, the same one as in the examples in Creating Alarms Using Automation Console and Creating Alarms Using NuoDB Manager) looks as follows:

{
"name": "avg-cpu-60",
"description": "average CPU ...",     
"eventType": "StatAlert",             eventType: always "StatAlert"
"dimension": "Domain",                dimension: Domain, Database, Host, or Node
"entityId": "",                       
"breachDuration": 1200,               breachDuration: in seconds, unlike the
"metric": "OS-cpuTotalTimePercent",   Automation Console which is minutes
"threshold": 60,                      threshold: all values are read as double
"operator": "GE",                     operator: GE, GT, EQ, etc.
"aggrFunc": "Average",                aggrFunc: "Average", "Sum", "None"
"severity": "Warning",                severity: See Alarm Severity
"repeat": "Reset",  
"action": "NotifyEvent"
}

Create this alarm (assuming the file is called mymetric.json and an Amazon EC2 instance) with the following command:

$ curl -X POST -u domain:bruin-H "Accept: application/json" -H "Content-type:application/json" 
-d @mymetric.json http://ec2-54-165-58-157.compute-1.amazonaws.com:8888/api/1/alarms/definitions
{"name":"avg-cpu-60","description":"average CPU ...","severity":"Warning","action":"NotifyEvent",
"entityId":"","eventType":"StatAlert","dimension":"Domain","breachDuration":1200,"repeat":"Reset",
"metric":"OS-cpuTotalTimePercent","threshold":60.0,"operator":"GE","aggrFunc":"Average"}
$