# Integrations

Alerts are sent to **channels**.

{% hint style="warning" %}
See [provisioning](https://github.com/lensesio-dev/docs/blob/release/6.1/deployment/installation/automation/README.md) for integration into your CI/CD pipelines.
{% endhint %}

## AWS Cloud Watch

To send alerts to AWS Cloud Watch, you first need an AWS connection.&#x20;

Go to **Environments->\[Your Environment]->Configuration**

Select AWS Connection and enter the required fields in the editor.

{% hint style="info" %}
Rather than enter your AWS credentials you can use the [AWS credentials chain](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials-chain.html#credentials-default).
{% endhint %}

Next, go to **Environments->\[Your Environment]->Alerts->Channels** and create a new channel for AWS connection.

## Datadog

To send alerts to Datadog, you first need a Datadog connection.&#x20;

1. Go to **Environments->\[Your Environment]->Configuration** and select **DataDog** and enter your required details in the editor.
2. Go to **Environments->\[Your Environment]->Alerts->Channels** and create a new channel with your connection.

## Pager Duty

To send alerts to Pager Duty, you first need a Pager Duty connection.

1. Go to **Environments->\[Your Environment]->Configuration** and select **PagerDuty** and enter your required details in the editor.
2. Go to **Environments->\[Your Environment]->Alerts->Channels** and create a new channel with your connection.

## Prometheus Alert Manager

To send alerts to **Alert Manager**, you first need a **Alert Manager** connection.&#x20;

* Go to **Environments->\[Your Environment]->Configuration** and select **Alert Manager** and enter your required details in the editor.
* Go to **Environments->\[Your Environment]->Alerts->Channels** and create a new channel with your connection.

## Slack

To send alerts to **Slack**, you first need a **Slack** connection.&#x20;

* Go to **Environments->\[Your Environment]->Configuration** and select **Slack** and enter your required details in the editor.
* Go to **Environments->\[Your Environment]->Alerts->Channels** and create a new channel with your connection.

## Webhook

Webhooks allow you to send alerts to any service implementing them, they are very flexible.

To send alerts to **Webhooks**, you first need a **Webhook** connection.&#x20;

* Go to **Environments->\[Your Environment]->Configuration** and select **Webhook** and enter your required details in the editor.
* Go to **Environments->\[Your Environment]->Alerts->Channels** and create a new channel with your connection.

### Template variables <a href="#template-variables" id="template-variables"></a>

In `Request path`, `HTTP Headers` and `Body payload` there is a possibility of using template variables, which will be translated to alert specific fields. To use template variables, you have to use this format: `{{VARIABLE}}`, i.e. `{{LEVEL}}`.

Supported template variables:

* LEVEL - alert level (`INFO`, `LOW`, `MEDIUM`, `HIGH`, `CRITICAL`).
* CATEGORY - alert category (`Infrastructure`, `Consumers`, `Kafka Connect`, `Topics`, `Producers`).
* INSTANCE - (broker url / topic name etc.).
* SUMMARY - alert summary - same content in the Alert Events tab.
* TIMESTAMP
* ID - alert global id (i.e. `1000` for BrokerStatus alert).
* CREDS - `CREDS[0]` etc. - variables specified in connections `Credentials` as a list of values separated by a comma.

## Webhook Email

To configure real-time email alerts you can leverage Webhooks, for example with the following service:

* Twilio and SendGrid
* Zapier

### SendGrid Example

1. Create a webhook connection, for SendGrid with **api.sendgrid.com** as the **host** and enable **HTTPS**
2. Configure a channel to use the connect you just created
3. Set the method to Post
4. Set the request path to the webhook URL from your Zapier account
5. Set the Headers to

| HTTP Headers                                   |
| ---------------------------------------------- |
| Authorization: Bearer \[your-Sendgrid-API-Key] |
| Content-Type: application/json                 |

6. Set the payload to be

```json
{
  "personalizations":[{
    "to":[{
      "email":"devops@mycompany.com",
      "name":"DevOps & SRE team | MyCompany"
    }],
    "subject":"PRODUCTION | Streaming Data Platform Alert"
  }],
  "content":[{
    "type":"text/html",
    "value":"<html><body><p>Priority Level:{{LEVEL}}</br></br>Category: {{CATEGORY}}</br><br>Description: {{SUMMARY}}</br><small>Alert ID: {{ID}}</small></p></body></html>"
  }],
  "from":{
    "email":"sender-email-address",
    "name":"sender name ie. PRODUCTION | Streaming Data"
  },
  "reply_to":{
    "email":"reply-to-email-address",
    "name":"reply to name"
  }
}
```

Change the above payload according to your requirements, and remember that the **\[sender-email-address]** needs to be the same email address you registered during the **Sender Authentication** Sendgrid setup process.

### Zapier Example

1. Create a webhook connection, for SendGrid with **hooks.zapier.com** as the **host** and enable **HTTPS**
2. Configure a channel to use the connect you just created
3. Set the method to Post
4. Set the request path tp **/v3/mail/send**
5. Set the request path to the webhook URL from your Zapier account
6. Set the Headers to:

```
X-Api-Token: {{CREDS[0]}
```

7. Set the payload to be

```html
<html>
  <body>
    <h2>Streaming data platform - alert</h2>
    <p>Environment: <a href="http://enjoy.lenses.io"><b>PRODUCTION</b></a></p>
    <p>Priority Level: <b>{{LEVEL}}</b></p>
    <p>Category: <b>{{CATEGORY}}</b></p>
    <p>Summary: {{SUMMARY}}</p>
    <p>Alert ID: {{ID}}</p>
    <p><small>Lenses.io</small></p>
  </body>
</html>
```

## Webhook MS Teams

To create a webhook in your MS Teams workspace you can use [this guide](https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).

At the end of the process you get a url of the format:\
[https://YOUR\_URL.webhook.office.com](https://your_url.webhook.office.com/)`/webhook2/<secret-token-by-ms>/IncomingWebhook/<secret-token-by-ms>`

You’ll need the second part

`/webhook2/<secret-token-by-ms>/IncomingWebhook/<secret-token-by-ms>`

1. Create a new Webhook Connection, set the host to **outlook.office.com** and enable **HTTPS**
2. Configure an new channel, using this connection
3. Set the Method to **POST**
4. The Request Path to the second part of the URL you recieved from MS Teams

`/webhook2/<secret-token-by-ms>/IncomingWebhook/<secret-token-by-ms>`

5. In the body set

```json
{"text": "{{CATEGORY}} {{LEVEL}} {{ID}}"}
```

## Webhook SMS

See Zapier and follow blog post [SMS alerts with Zapier](https://lenses.io/blog/2020/06/sms-kafka-alerts/).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenses.io/latest/devx/6.1/user-guide/monitoring-and-alerting/integrations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
