2.5. Set up notifications

In most cases you, and perhaps several people on your team, will be interested in multiple alerts. Cloud Monitoring lets you set up notification plans that can be shared between multiple alerts. In this exercise, you create the notification first, then the notification plan, and then finally the alarms. Note that you can create alarms and notifications in any order you choose, or simply modify an existing record to create a new one. However, to create an a notification plan, you do need to create a notification first.

First you create an email notification, which will be an attribute to the notification plan.

 

Example 2.23. Create notification request: cURL

curl -i -X POST \
--data-binary \
   '{ "details" : { "address" : "joe@example.org" },
  "label" : "Alert email 1",
  "type" : "email"
}' \
-H 'X-Auth-Token: auth_token' \
-H 'Content-Type: application/json' \
'https://monitoring.api.rackspacecloud.com/v1.0/010101/notifications'


 

Example 2.24. Create notification response: cURL

HTTP/1.1 201 Created
X-Ratelimit-Remaining: 49964
X-Response-Id: .rh-00oi.h-ord1-maas-prod-api1.r-WZWtj0Vc.c-5711.ts-1329408343356.v-b9d7626
Content-Length: 0
X-Lb: ord1-maas-prod-api1
X-Ratelimit-Type: global
X-Ratelimit-Limit: 50000
Location: https://monitoring.api.rackspacecloud.com/v1.0/010101/notifications/nt2T8WtWte
Date: Thu, 16 Feb 2012 16:05:43 GMT
X-Ratelimit-Window: 24 hours
Content-Type: text/plain


 

Example 2.25. Create notification request: raxmon

raxmon-notifications-create --label="Alert email 1" --type=email --details=address=joe@example.org 


 

Example 2.26. Create notification response: raxmon

Resource created. ID: nt2T8WtWte


If the notification is successfully created, the endpoint returns a response code of 201 and a Location: Header containing the URL of the notification. If an error message is returned, the endpoint was unable to create the notification.

NEXT UP: Create a notification plan so you can receive a message when your entity is in different states.

 2.5.1. Create a notification plan

A notification represents a single action, whereas a notification plan represents a set of actions. Assuming the ID of the notification you created is nt2T8WtWte, here's an example of how you might specify the attributes for a notification plan:

label

Specifies a descriptive name for the notification plan.

warning_state

Specifies a list of notification ids to send when the state is WARNING.

critical_state

Specifies a list of notification ids to send when the state is CRITICAL.

ok_state

Specifies a list of notification ids to send when the state is OK.

In this case, you're configuring the system to send an email when a state changes.

 

Example 2.27. Create notification plan request: cURL

curl -i -X POST \
--data-binary \
'{
      "label": "Notification Plan 1",
      "warning_state": [
          "nt2T8WtWte"
      ], 
      "critical_state": [
          "nt2T8WtWte"
      ], 
      "ok_state": [
         "nt2T8WtWte"
      ]
}' \
-H 'X-Auth-Token: 6auth_token' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
'https://monitoring.api.rackspacecloud.com/v1.0/010101/notification_plans'

 

Example 2.28. Create notification plan response: cURL

HTTP/1.1 201 Created
X-Ratelimit-Remaining: 49958
X-Response-Id: .rh-ew99.h-dfw1-maas-prod-api1.r-dRuk75SF.c-35593.ts-1329410023443.v-b9d7626
Content-Length: 0
X-Lb: dfw1-maas-prod-api0
X-Ratelimit-Type: global
X-Ratelimit-Limit: 50000
Location: https://monitoring.api.rackspacecloud.com/v1.0/010101/notification_plans/npkmLh5vVk
Date: Thu, 16 Feb 2012 16:33:43 GMT
X-Ratelimit-Window: 24 hours
Content-Type: text/plain

 

Example 2.29. Create notification plan request: raxmon

raxmon-notification-plans-create --label="Notification Plan 1" --critical-state=nt2T8WtWte --warning-state=nt2T8WtWte --ok-state=nt2T8WtWte 

 

Example 2.30. Create notification plan response: raxmon

Resource created. ID: npkmLh5vVk

If the endpoint responds with a 201 and a Location: Header containing the URL of the new notification plan, the notification plan was created. If the notification plan was not created, an error is returned.

NEXT UP: Create an alarm for the entity and associate it with your notification plan.