Integration with AWS Batch

Overview

The following example demonstrates how to start an AWS Batch job using a AWS API outgoing webhook.

The request is automatically signed with AWS Signature, v4, implemented by this notification type, which allows submitting requests to any AWS endpoint that accepts AWS Signature, v4.

The example described below invokes the AWS Batch API SubmitJob action.

Configuration

Create a new AWS API webhook or import the template used in this example. To import the XML template file, open the Alerts > Outgoing Webhooks page, select Import in the split button located below the table and follow the prompts.

To create a new notification, open the Alerts > Outgoing Webhooks page and click Create.

Parameters

Enter a name and specify the following parameters:

Name Value
Endpoint URL https://batch.<AWS_REGION>.amazonaws.com/v1/submitjob
Method POST
Content Type application/json
Access Key Id <AWS_ACCESS_KEY_ID>
Secret Access Key <AWS_SECRET_ACCESS_KEY>
Body <JSON_CONTENT>

Modify the Endpoint URL by replacing the <AWS_REGION> value with the target region, for example:

https://batch.us-east-1.amazonaws.com/v1/submitjob

Enter the AWS key id into the Access Key Id field and the secret key into the Secret Access Key field.

Modify the Body by replacing the <JSON_CONTENT> value with actual values, for example:

{
  "jobName": "forecast-energy-job",
  "jobQueue": "hourly-forecast-energy-01",
  "jobDefinition": "job-definition"
}

Rule

Create a new rule or import the rule template used in this example. To import the XML template file, open the Alerts > Rules page, select Import in the split button located below the table and follow the prompts.

To create a new rule, open the Alerts > Rules page and click Create.

Specify the key settings on the Overview tab.

Name Value
Status Enabled
Metric test_m
Condition value > 1

Open the Webhooks tab.

Set Enabled to Yes and choose the previously created webhook from the Endpoint drop-down.

Enable Open trigger.

Test

Test the integration by submitting a sample series command on the Data > Data Entry page.

  series e:test_e m:test_m=2

The value causes the condition to evaluate to true, which in turn triggers the notification. To verify that an alert was raised, open Alerts > Open Alerts page and check that an alert for the test_m metric is present in the Alerts table.

Check the AWS Batch job status: