Opsgenie Actions enable you to automate manual, repetitive tasks so that your resources are freed up to concentrate on higher-value work. This blog post is the second in a series of use cases in which we discuss how Opsgenie works with various third-party automation platforms to automate these traditionally manual tasks—right from the Opsgenie console or mobile app— to reduce interruptions for your on-call responders, and ultimately help your bottom line.

In response to an alert, Opsgenie Actions can adjust AWS resources via an “action.” A possible application of this is to execute AWS Systems Manager (SSM) automation documents to adjust AWS resources. Repetitive remediation actions such as starting an EC2 instance, updating the capacity of a table, or taking snapshots can be done easily by executing SSM documentation via Opsgenie Actions. Keep reading to see how it’s done.

 AWS-StartEC2 performs a series of actions to start an EC2 instance automatically. When an instance state changes from running to stopped, an Opsgenie Action can be defined to trigger this document to quickly restart the instance without logging into AWS console.

Step 1: Action Channel

To execute an AWS SSM document, you need to first define an “action channel”— which includes the connection credentials to your AWS account. Name your channel, then select your region. Next, you need to define an IAM role with necessary permissions and trust relationships. Use the link provided in the “AWS Role” dialogue box to create an IAM role via CloudFormation template. Be sure to confirm that your IAM role includes all permissions to execute the document. You can view the AWS SSM document, here.

Create the Action Channel in Opsgenie

Step 2: Manage and define the Action

Once the action channel is configured, it’s time to define the Opsgenie Action. Click the “Add Action” button and select the “Type” as “AWS Systems Manager”. Then, select the channel you created at Step 1. Next, select “AWS-StartEC2” from the AWS SSM Documents drop down list and click “Next” to configure parameters.

Opsgenie Actions allow you to customize the parameters. You can also configure the parameters to either be “Predefined”, meaning they don’t require live intervention,  or require the user to enter them at run time by selecting the “Prompt User” option. Prompting the user allows you to specify values at run time using a drop down, check box, or free form text.  Please note, the parameters and their requirement conditions are retrieved from AWS directly.

Opsgenie Actions can be added on an alert by using “Alert Policies” or integrations. Opsgenie’s CloudWatch Events integration can be used for tracking the instance state. By using this integration, you will receive an alert from Opsgenie whenever the instant state changes from “running” to “stopped”. Add “Start EC2 action” to the CloudWatch Events integration via the “Advanced Integration” settings shown below:

Configure CloudWatch events from the advanced tab of the integration.

Step 3: Action execution

When a “stopped” instance alert occurs the “Start EC2” action will automatically recognize the instance ID and the corresponding action (“Start Instance”). This way, the instance is quickly started without having to log in to the AWS console thereby reducing response time. Actions can be executed from the mobile app as well.

Action execution

Opsgenie also offers Action Policies to execute actions. When an instance is stopped, you can define a policy to execute action without response of on-call person. To define the Action Policy from the Teams page, click the “Policies tab. Here, you can automatically trigger an action without having to notify a responder first.

The image below demonstrates an Action Policy set to trigger the “Start Instance” action 1 minute after the alert is created. This means, no one is getting up in the middle of the night to complete a remedial task and they can rest up until an incident occurs that truly needs their attention.

Action policy triggering.

This is just one application of Opsgenie Actions that illustrates how using this feature can reduce your MTTR and increase the time and resources available for higher-value work. Be sure to keep an eye out for our other use cases in the coming weeks.

Interested in trying Opsgenie Actions for yourself? Sign up for early access, contact us through the blue chat bubble on our homepage to enable this feature for you.

Automate resource adjustments for Amazon EC2 with ...