Datadog
  • 02 Feb 2023
  • 3 Minutes to read
  • Dark
    Light

Datadog

  • Dark
    Light

Article Summary

The Datadog integration enables you to trigger workflows with Datadog events, search logs, and get/post events to Datadog from Torq workflows.

Use Datadog to trigger Torq workflows

  • Create a Datadog trigger integration
  • Define monitors to trigger workflows in Torq

Create a Datadog trigger integration in Torq

  1. Go to the Integrations page, locate the Datadog card, and click Add.
  2. Enter a meaningful name for the integration and click Add.
  3. Copy the Webhook URL that is generated. You'll need this URL when you configure a Webhook integration in your Datadog tenant.

Define the monitors to trigger Torq workflows

🗒️ NOTE

By default, payload values are wrapped in quotation marks. This will cause them to be read as a string in Torq and likely cause an issue. If your variable contains a JSON, remove the quotation marks and it will process properly.

For more information, see the troubleshooting section.

  1. Go to Integrations > Integrations, click the Webhooks card, and click New.Screenshot of going to the webhook card in Datadog.
  2. Enter a meaningful name for the Webhook integration and paste the Webhook URL that you generated in Torq. The integration name is how you'll the identifier (remember to use it later in specific Datadog monitors to trigger Torq) and the Webhook URL from the previous step.Screenshot of creating a webhook in Datadog.
  3. Torq recommends adding additional alert information to the payload. You can use portions of the below configuration.
    JSON
    {
        "body": "$EVENT_MSG",
        "title": "$EVENT_TITLE",
        "date": "$DATE",
        "id": "$ID",
        "metadata": {
            "AGGREG_KEY": "$AGGREG_KEY",
            "ALERT_CYCLE_KEY": "$ALERT_CYCLE_KEY",
            "ALERT_ID": "$ALERT_ID",
            "ALERT_METRIC": "$ALERT_METRIC",
            "ALERT_QUERY": "$ALERT_QUERY",
            "ALERT_SCOPE": "$ALERT_SCOPE",
            "ALERT_STATUS": "$ALERT_STATUS",
            "ALERT_TITLE": "$ALERT_TITLE",
            "ALERT_TRANSITION": "$ALERT_TRANSITION",
            "ALERT_TYPE": "$ALERT_TYPE",
            "EMAIL": "$EMAIL",
            "EVENT_MSG": "$EVENT_MSG",
            "EVENT_TITLE": "$EVENT_TITLE",
            "EVENT_TYPE": "$EVENT_TYPE",
            "HOSTNAME": "$HOSTNAME",
            "ID": "$ID",
            "LAST_UPDATED": "$LAST_UPDATED",
            "LINK": "$LINK",
            "METRIC_NAMESPACE": "$METRIC_NAMESPACE",
            "ORG_ID": "$ORG_ID",
            "ORG_NAME": "$ORG_NAME",
            "PRIORITY": "$PRIORITY",
            "SNAPSHOT": "$SNAPSHOT",
            "TAGS": "$TAGS",
            "TEXT_ONLY_MSG": "$TEXT_ONLY_MSG",
            "USER": "$USER",
            "USERNAME": "$USERNAME",
            "LOGS_SAMPLE": "$LOGS_SAMPLE"
        }
    }
  4. Pick monitors that will trigger Torq workflows. In the Alert Your Team field add a reference to the newly created Webhook integration. For more information, see the Datadog documentation.

Use Datadog steps in Torq workflows

You need to create a Datadog API key and an application key, which you'll use as input parameters for Datadog steps in Torq. Some Datadog steps in Torq require an API key and application key, and some require the Datadog integration.

Create an API key in Datadog

After you create the API key, make sure you copy and save it. You won't be able to access it later. For more information about API keys, see the Datadog documentation.

  1. Hover over your user name and select Organization Settings.
  2. From the left panel, click API Keys.
  3. Click + New Key.Screenshot showing how to create an API key in Datadog.
  4. Enter a meaningful name for the API key, such as, Torq, and click Create Key.
  5. Copy the Key and save it. You will need this key when creating a Datadog integration in Torq.

Create an application key in Datadog

After you create the application key, make sure you copy and save it. You won't be able to access it later. For more information about application keys, see the Datadog documentation.

  1. Hover over your user name and select Organization Settings.
  2. From the left panel, click Application Keys.
  3. Click + New Key.Screenshot showing how to create an app key in Datadog.
  4. Enter a meaningful name for the application key, such as Torq, and click Create Key.
  5. Copy the Key and save it. You will need this key when creating a Datadog integration in Torq.

Create a Datadog steps integration in Torq

  1. Go to the Integrations page, locate the Datadog card in the Steps section, and click Add.
  2. Enter a meaningful name for the integration, such as Datadog-<monitor_type>.
  3. Enter the Datadog API key and app key, and click Add.

Premade steps

  • Get events
  • Post an event
  • Search logs

Collected data

Data that the Torq integration collects.

Metrics

The Torq integration does not provide any metrics.

Events

The Torq integration allows you to send events to your Datadog event stream from a Torq workflow using the step Datadog Post Event step. You can use the step with your playbooks to notify Datadog about successful mitigations, execution failures and send enriched alert data back to Datadog.

Service Checks

The Torq integration does not include any service checks

Troubleshooting

Some common issues you might experience.

JSON Parsing as String

In the example below, the value of the $LOGS_SAMPLE variable is a JSON object. In order for the event to be parsed correctly in Torq, you need to remove the double quotes.

JSON
{
    "Logs": "$LOGS_SAMPLE",
    "last_updated": "$LAST_UPDATED",
    "event_type": "$EVENT_TYPE",
    "title": "$EVENT_TITLE",
    "date": "$DATE",
    "org": {
        "id": "$ORG_ID",
        "name": "$ORG_NAME"
    },
    "id": "$ID"
}

The result will look like this:

JSON
{
    "Logs": $LOGS_SAMPLE,
    "last_updated": "$LAST_UPDATED",
    "event_type": "$EVENT_TYPE",
    "title": "$EVENT_TITLE",
    "date": "$DATE",
    "org": {
        "id": "$ORG_ID",
        "name": "$ORG_NAME"
    },
    "id": "$ID"
}

Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.