Email alerting

Based on the Kaa v1.2.

Time to complete: 17 min.


Welcome to the fifth tutorial in the Kaa getting started guide! We assume that you have successfully connected your first device to Kaa, collected data from a device, and sent alerts with Open Distro so make sure to review those tutorials before proceeding here.

From this tutorial, you will learn how to configure an webhook destination for Open Distro that will be triggered to send an email when a certain telemetry value from the endpoint exceeds a defined threshold.

We will use for email sending.

Open Distro integration

We assume that you have successfully completed Open Distro Alerting tutorial and remember the theory but let’s recap what is Open Distro. Open Distro is open-source distribution of Elasticsearch with advanced security, alerting, SQL support, automated index management, deep performance analysis, and more. Kaa forwards all telemetry data from your endpoints into Elasticsearch index attached to your tenant.


Create bot on

Register an account on then go to Bots and click Create a Bot button. Search and select Webhooks for the Trigger app and Incoming Hook for the trigger event. Search and select Email for the Action app and Send an Email for the Action to be done.

Setup webhook first phase

Click Setup Webhook on the left and and you will be redirected to the Setup Webhook page with the webhook URL. Leave this page opened, we will return to it in a moment.

Create webhook destination

We assume that you have already created CO2 monitor and trigger during completing the previous Open Distro Alerting tutorial so that your monitor looks next:

WHEN max()
OF dataSample.co2
OVER all documents
FOR THE LAST 1 minute(s)
WHERE dataSample.co2 is greater than 1000

and trigger is IS ABOVE 1,000.

If you don’t have the above monitor and trigger, go to the Open Distro Alerting and create them. It won’t take much time. Meantime, we will wait you here ;)

To create a webhook destination, go to the Alerting, Destination and click Add destination button.

Add destination button

Enter “Email destination” into the Name field. Select Custom webhook for the Type field. Go the the earlier opened page with the URL on the, copy the URL and paste it into the Webhook URL field.

Setup destination

Click Create.

Go to Monitors, click on your monitor (it was named CO2 level monitor in the previous tutorial), find CO2 level trigger, select it and click Edit. Scroll to the bottom and click and click Add action.

Enter “Email action” for the Action name field.

Select just created Email destination for the destination field and paste the next text for the Message field: {"message": "CO2 level is {{ctx.results.0.aggregations.when.value}} ppm"}.

Now complete bot setup on For that, click Send test message

Send test message button

return back to the page with webhook URL on the and click I’m Done. Just sent test message must appear.

Webhook test

Click Looks Good and the current page will close. Return to the action configuration page on Kibana and save changes.

Go the bot setup page and fill in From Name, To Addresses, Subject and drag and drop message output field into the Email Body

Setup webhook second phase

Save your changes, enable the bot, click Enter Sample Data and click Run Test button.

Run bot test

The mail must arrive to the specified To Address email.

Test mail

Report high CO2 level

Let’s report that CO2 equals 1200 and see what happens.

Simulate a high CO2 level by invoking the next cURL. Don’t forget to replace <app-version-name> and <endpoint-token> with your application version name and the endpoint token respectively.

curl --location --request POST '<app-version-name>/dcx/<endpoint-token>/json' \
--data-raw '{
  "co2": 1200

Within a minute you should receive an alerting mail.

Alert mail

View alerts history

To view alerts history, go to the alerting dashboard.

Alerts history

Learn more


This tutorial is based on Kaa 1.2 released on July 6-th, 2020. If you, our reader from the future, spot some major discrepancies with your current version of the Kaa platform, or if anything does not work for you, please give us a shout and we will help!

And if the tutorial served you well, we’d still love to hear your feedback, so join the community!