• Products
  • Get started
  • Documentation
  • Resources

Integrate Opsgenie with Incoming Amazon SNS

Overview

Amazon SNS makes it simple and cost-effective to push notifications to Apple, Google, Fire OS, and Windows devices, as well as Android devices in China with Baidu Cloud Push.

​What does the integration offer?

Opsgenie acts as a dispatcher for Amazon SNS notifications, determines the right people to notify based on on-call schedules– notifies via them using email, text messages (SMS), phone calls, and iPhone & Android push notifications, and escalates alerts until the alert is acknowledged or closed.

How does the integration work?

When an alert is created in SNS, an alert is created in Opsgenie automatically through the integration.

Set up the integration

Amazon SNS is an API-based integration. Setting it up involves the following steps:

  • Add an Amazon SNS integration in Opsgenie

  • Set up a subscription in Amazon SNS

Add an Amazon SNSintegration

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 Amazon SNS integration in Opsgenie:

  1. Go to Settings > Integrations.

  2. Select Add integration.

  3. Run a search and select “Amazon SNS”.

  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 integration URL, which includes Opsgenie’s endpoint and the API key.
    You will use this URL while configuring the integration in Amazon SNS later.

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

Set up a subscription in Amazon SNS

1. Create an SNS topic.
For details, see Getting started with Amazon SNS.

2. Add an HTTPS subscription to your topic with the URL you copied while adding the integration in Opsgenie as the endpoint.

Amazon SNS Subscription

If the configuration is successful, a confirmation alert is created in Opsgenie. For details on how to add an HTTPS subscription, see Subscribing to an Amazon SNS topic - Amazon Simple Notification Service.

3. Specify the alert's alias, entity, tags, recipients, teams, and custom actions using message attributes.
For details, see Amazon SNS message attributes.

SNS message attributes

(in plain text format)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 AmazonSNSClient snsClient = new AmazonSNSClient(new BasicAWSCredentials("AWS_ACCESS_KEY","AWS_SECRET_KEY")); String msg = "This is the description of Sns Integration test alert"; String subject = "Sns Integration Test alert"; PublishRequest publishRequest = new PublishRequest("arn:aws:sns:us-east-1:974xxxxxxx:OpsGenieSns", msg, subject); publishRequest.addMessageAttributesEntry("eventType", new MessageAttributeValue() .withDataType("String").withStringValue("create")); publishRequest.addMessageAttributesEntry("alias", new MessageAttributeValue() .withDataType("String").withStringValue("testalertalias")); publishRequest.addMessageAttributesEntry("entity", new MessageAttributeValue() .withDataType("String").withStringValue("Test alert entity")); publishRequest.addMessageAttributesEntry("tags", new MessageAttributeValue() .withDataType("String").withStringValue("trial")); publishRequest.addMessageAttributesEntry("recipients", new MessageAttributeValue() .withDataType("String").withStringValue("none")); publishRequest.addMessageAttributesEntry("teams", new MessageAttributeValue() .withDataType("String").withStringValue("team1,team2")); publishRequest.addMessageAttributesEntry("actions", new MessageAttributeValue() .withDataType("String").withStringValue("customAction")); PublishResult publishResult = snsClient.publish(publishRequest);

All the fields in "MessageAttributes" are optional. To specify the action to run, send the "eventType" field. An alert is created if "eventType" is not specified. To run actions, specify "eventType" as follows:

  • create action > "eventType" : {"Type":"String","Value":"create"}

  • close action > "eventType" : {"Type":"String","Value":"close"}

  • acknowledge action > "eventType" : {"Type":"String","Value":"acknowledge"}

  • add note action > "eventType" : {"Type":"String","Value":"addNote"}

Sample payload sent from Amazon SNS

Create alert payload (in JSON format)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 { "Type" : "Notification", "MessageId" : "0323d595-6aed-5dd4-a378-9811daf7d3ed", "TopicArn" : "arn:aws:sns:us-east-1:9747xxxxxxx:gj", "Subject" : "Sns Integration Test alert", "Message" : "This is the description of Sns Integration test alert", "Timestamp" : "2015-03-18T15:24:31.877Z", "SignatureVersion" : "1", "Signature" : "QplK4lyJWAtjIV9BzcF4AHTKT+VTupYqJIzxxxxxxxxxxx4QR8EdAYr31xDjI8...", "SigningCertURL" : "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-dxxxxd67.pem", "UnsubscribeURL" : "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe..", "MessageAttributes" : { "alias" : {"Type":"String","Value":"testalertalias"}, "entity" : {"Type":"String","Value":"snstestentity"}, "tags" : {"Type":"String","Value":"tag1,tag2"}, "eventType" : {"Type":"String","Value":"create"}, "recipients" : {"Type":"String","Value":"all"}, "teams" : {"Type":"String","Value":"team1,team2"}, "actions" : {"Type":"String","Value":"act1,act2"} } }

Still need help?

The Atlassian Community is here for you.