• Products
  • Get started
  • Documentation
  • Resources

Integrate Opsgenie with Amazon CloudWatch

Overview

CloudWatch metrics play a critical role in monitoring the applications running on AWS cloud.

What does the integration offer?

A CloudWatch alarm watches a single metric over a specified time period and executes automated actions based on the value of the watched metric and given threshold. Opsgenie acts as a dispatcher for these alarms. It determines the right people to notify based on on-call schedules– notifies them using email, text messages (SMS), phone calls, and iPhone & Android push notifications, and escalates alerts until the alert is acknowledged or closed. CloudWatch detects problems, and Opsgenie ensures the right people are working on them.

How does the integration work?

When an alert is created in CloudWatch, an alert is created in Opsgenieautomatically through the integration. When the alert is closed in CloudWatch, the related alert is automatically closed in Opsgenie through the integration.

Set up the integration

AWS CloudWatch is an API-based integration. Setting it up involves the following steps:

  • Add an AWS CloudWatch integration in Opsgenie

  • Set up alarms in AWS CloudWatch

Add an Amazon CloudWatch integration

If you're using Opsgenie's Free or Essentials plan or if you’re using Opsgenie with Jira Service Management's Standard plan, you can add this integration from your team dashboard only. The Integrations page under Settings is not available in your plan.

  1. Go to Teams and select your team.

  2. Select Integrations on the left navigation and then select Add integration.

Adding the integration from your team dashboard will make your team the owner of the integration. This means Opsgenie will assign the alerts received through this integration to your team only. Follow the rest of the steps in this section to set up the integration.

To add an AWS CloudWatch integration in Opsgenie:

  1. Go to Settings > Integrations.

  2. Select Add integration.

  3. Run a search and select “AWS CloudWatch”.

  4. On the next screen, enter a name for the integration.

  5. Optional: Select a team in Assignee team if you want a specific team to receive alerts from the integration.

  6. Select Continue.
    The integration is saved at this point.

  7. Expand the Steps to configure the integration section and copy the endpoint URL generated for your account.
    You will use this URL while configuring the integration in AWS CloudWatch later.

  8. Select Turn on integration.
    The rules you create for the integration will work only if you turn on the integration.

Set up alarms in CloudWatch

1. Create an SNS topic with the name “Opsgenie”.

2. Add an HTTPS subscription to the topic with the Opsgenie API endpoint URL. This is the endpoint URL you copied while adding the integration in Opsgenie.

CloudWatch SNS Topic

If the configuration is successful, a confirmation alert is created in Opsgenie.

3. Create a CloudWatch alarm with any metric and select the SNS topic as the action.

CloudWatch alarm actions

Ensure that the alarm name includes resource and metric names for uniqueness and ease of readability. For example, SQS Queue chat_webhook messageCount Too High. Ensure that notifications are sent for all of the states ALARM, OK, and INSUFFICIENT to Opsgenie. Notifications with state ALARM create alerts, and notifications with states OK and INSUFFICIENT close the matching alerts by default.

The integration creates an alias for each alert using Region - AlarmName, by default. This way, Opsgenie uniquely identifies each CloudWatch alarm, creates, and closes them respectively.

Test the alerts

  1. After setting up notifications for an alarm in CloudWatch, modify the alarm threshold for testing purposes so that it creates an alarm.

  2. When the alarm condition is met, AWS CloudWatch passes alarm details to Opsgenie, and Opsgenie notifies the specified users (recipients parameter) based on the recipients’ notification preferences. The Opsgeniealert contains all the relevant information provided by CloudWatch.

  3. Revert the CloudWatch alarm threshold configuration back to its original after testing is complete.

Sample payload sent from CloudWatch

Create alert payload (in JSON format)

1 2 3 4 5 6 7 8 9 10 11 12 { "Type": "Notification", "MessageId": "1cf7a0eb-4179-4181-b15b-ea22c5aa0280", "TopicArn": "arn:aws:sns:us-east-1:08931xxxxxx:CloudWatchHTTPAlarms", "Subject": "ALARM: \"cpuUtilTest\" in US - N. Virginia", "Message": "{\"AlarmName\":\"cpuUtilTest\",\"AlarmDescription\":\"testing alarms for cpu utilization\",\"AWSAccountId\":\"08931xxxxxx\",\"NewStateValue\":\"ALARM\",\"OldStateValue\":\"OK\",\"NewStateReason\":\"Threshold Crossed: 1 datapoint (5.199) was greater than or equal to the threshold (5.0).\",\"StateChangeTime\":\"2012-08-05T22:31:25.524+0000\",\"Region\":\"US - N. Virginia\",\"Trigger\":{\"MetricName\":\"CPUUtilization\",\"Namespace\":\"AWS/EC2\",\"Statistic\":\"AVERAGE\",\"Unit\":null,\"Dimensions\":[{\"name\":\"InstanceId\",\"value\":\"i-39e64c5f\"}],\"Period\":900,\"EvaluationPeriods\":1,\"ComparisonOperator\":\"GreaterThanOrEqualToThreshold\",\"Threshold\":5.0}}", "Timestamp": "2012-08-05T22:31:30.673Z", "SignatureVersion": "1", "Signature": "XrsO2wtE0b+ofOl1ZxxxxxxxxlimTUg+rV4U9RmNSSBEdlmyWvtGgpjebsmNv1wkjUsBQOJZjZnpZp5FBn6quAn3twNdRMmMLf15lv6ESbYFxxxxxxxx0vmjj/ZLwiH9Pr/cxVYxxxxxxxYn8w6g=", "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c72xxxxxxxxx6de52f.pem", "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:08931xxxxxxxx:CloudWatchHTTPAlarms:1841c5ca-ddda-450e-bbfb-xxxxxxxxx" }

Payload parsed by Opsgenie (in JSON format)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 { "TopicArn": "arn:aws:sns:us-east-1:08931xxxxxxx:CloudWatchHTTPAlarms", "AlarmName": "cpuUtilTest", "Subject": "ALARM: \"cpuUtilTest\" in US - N. Virginia", "AlarmDescription": "testing alarms for cpu utilization", "NewStateReason": "Threshold Crossed: 1 datapoint (5.199) was greater than or equal to the threshold (5.0).", "NewStateValue": "ALARM", "OldStateValue": "OK", "StateChangeTime": "2012-08-05T22:31:25.524+0000", "Region": "US - N. Virginia", "Trigger": { "MetricName": "CPUUtilization", "Namespace": "AWS/EC2", "Statistic": "AVERAGE", "Unit": null, "Dimensions": [ { "name": "InstanceId", "value": "i-39e64c5f" } ], "Period": 900, "EvaluationPeriods": 1, "ComparisonOperator": "GreaterThanOrEqualToThreshold", "Threshold": 5 } }

Still need help?

The Atlassian Community is here for you.