Examples

Let's look at a few subscription examples. The first example sends a message to a Slack channel when an event occurs. The second example calls an external API when an event occurs. The third example sends an email when an event occurs.

Send a Message to a Slack Channel

Your operations team needs to quickly respond to data SLA alerts. You want to create a subscription to send messages to an Operations Slack channel each time a data SLA alert triggers.

You use the following steps to create the subscription:
  1. Configure Slack for incoming webhooks for the channel you want to use.

    At the time of writing, you can enable webhooks in Slack starting from this page. When you enable webhooks, Slack generates a URL for you to use. If you have already enabled webhooks, check your account information for the Slack URL.

  2. Copy the URL that Slack generates.
    The URL looks something like this:
    https://hooks.slack.com/services/<random string>/<random string>/<random string>
  3. Create a subscription in Control Hub, selecting the data SLA triggered event.
  4. Under Actions, make the following configurations:
    • Select the Webhook action.
    • Select the POST HTTP method.
    • Enter the generated Slack URL.
    • Enter application/json for the content type.
    • Enter the payload text, using the Slack instructions for how to configure the payload.

    For Slack, you can accept the defaults for everything else.

    Here's how the configured Slack webhook action might look:

Call an External API

You can configure a subscription to call an external API when an event occurs. For example, you could call an API that you have designed that generates a weekly summary report of all job status changes. The API requires the job name, time that the job status change occurred, and the changed status sent in JSON format. You simply use parameters to configure the payload to send those values to the API.

The API requires basic authentication, so you'll need to enter an authorized user name and password when you configure the subscription.

To set up this example, you'd complete the following steps:
  1. Create a subscription in Control Hub, selecting the job status change event.
  2. Under Actions, select the Webhook action and the POST HTTP method.
  3. Enter the URI to call the external API, for example:
    http://api.my.server/rest/v2/trackControlHubJobStatus
  4. Enter application/json for the content type.
  5. In the payload, enter the data that the API expects in JSON format, for example:
    {
        "data":
          {
               "job":"{{JOB_NAME}}",
               "datetime":"{{TRIGGERED_ON}}",
               "status":"{{TO_STATUS}}"
          }
    }
  6. Select Basic for the authentication type and enter an authorized user name and password.

    Here's how the configured API webhook action might look:

Sending an Email

You can configure a subscription to send an email when an event occurs. For example, you can send an email to the organization administrator when someone commits a pipeline.

To set up this example, you'd complete the following steps:
  1. Create a subscription in Control Hub, selecting the pipeline committed event.
  2. Under Actions, select the Email action.
  3. Enter the email subject line and the email recipients.
  4. In the body, enter the message to send, for example:
    {{PIPELINE_COMMITTER}} committed the {{PIPELINE_NAME}} pipeline on {{PIPELINE_COMMIT_TIME}}.

Here's how the configured email action might look: