Skip to main content

Notification

Currently supported:

  • Email notification using self-serve UI
  • Notifications to Slack is supported using APIs
  • Notifications to PagerDuty will be available soon!

From ThirdEye UI

Steps to configure a subscription group to receive email notifications is as follows:

  • Click on Create

  • Create Subscription Group

  • Type the “Name of the Subscription Group”

  • Enter schedule in cron job style (cron -n|-p|-s|-m mailcommand). The cron schedule. Defines when and at what frequency the subscription notifications will be sent. The format used is the 6-7 fields Quartz cron format. See Quartz documentation. A cron expression builder is available here.

  • Enter Email id in “Subscribe Emails” section then click add

  • Select and add alerts (one by one) to be subscribed by clicking “->” next to alert name in the “All alerts” section. (this is an optional step)

  • Click Next and Finish

    imageimageimageimageConfigure Subscription Groups to subscribe to alerts and receive notifications

Creating a Subscription Group Using APIs

Use /api/subscription-groups to perform CRUD operations on subscription groups

Create a subscription group

Use POST /api/subscription-groups to create a subscription group. The payload is a list of subscription groups.

Here is a sample creating a subscription group with a single email notification channel. It is associated with a single alert. The alert is identified by its id.

[
{
"name": "sg-with-alert",
"alerts": [],
"alertAssociations": [
{
"alert": {
"id": 247243
}
}
],
"cron": "*/1 * * * * ?",
"specs": [
{
"type": "email-smtp",
"params": {
"from": "no-reply@startree.ai",
"smtp": {
"host": "${SMTP_HOST}",
"port": "${SMTP_PORT}",
"user": "${SMTP_USER}",
"password": "${SMTP_PASSWORD}"
},
"to": [
"your.email@gmail.com"
]
}
}
]
}
]

Here is the same example with a subscription group that is associated with an alert and an enumeration item. Here, in addition to the alert id we also specify the enumeration item id.

  {
"id": 250958,
"name": "sg-alert-and-enumeration-item",
"alerts": [],
"alertAssociations": [
{
"alert": {
"id": 247243
},
"enumerationItem": {
"id": 247397
}
}
],
"cron": "*/1 * * * * ?",
"specs": [
{
"type": "email-smtp",
"params": {
"emailRecipients": {
"from": "no-reply@startree.ai",
"to": [
"your.email@gmail.com"
]
},
"smtp": {
"host": "${SMTP_HOST}",
"port": "${SMTP_PORT}",
"user": "${SMTP_USER}",
"password": "${SMTP_PASSWORD}"
}
}
}
]
}

Slack [API Support]

All notification channels are hosted within subscription groups. CRUD operations can be performed as usual on subscription group entities using the /api/subscription-groups endpoint.

Step 1. Create a Slack App

Create a slack app for your workspace and add an incoming webhook. The webhook is tied to a specific channel and would look something like this.

https://hooks.slack.com/services/T1234567/AAAAAAAA/ZZZZZZ

Note that 1 app can support multiple incoming webhooks.

Optional: Subscription groups values can be populated via environment variables

To prevent the incoming webhook to be visible in plain text to any user, you can create an env variable (in Kubernetes, you can also leverage secrets to do this).

export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/T1234567/AAAAAAAA/ZZZZZZ"

Step 2. Create a subscription group

Here is a sample payload for creating the subscription group. You can submit this to POST /api/subscription-groups

 [
{
"name": "slack-webhook",
"cron": "*/1 * * * * ?",
"specs": [
{
"type": "slack",
"params": {
"webhookUrl": "${SLACK_WEBHOOK_URL}"
}
}
]
}
]

Step 3: Use your subscription group with any Alert

The subscription group can be tied to any alert as usual.

Also note that 1 subscription group supports multiple specs. Therefore, it can route to the same or different notification channels in the same subscription group.

Webhook [API Support]

The webhook notification allows you to input a url which thirdeye can use to POST a payload.

Here is a sample json payload to build a webhook notification.

 [
{
"name": "webhook",
"cron": "*/1 * * * * ?",
"specs": [
{
"type": "webhook",
"params": {
"url": "http://localhost:8080/internal/webhook"
}
}
]
}
]

The POSTed payload contains all the anomaly reports relevant for the notification service. Here's an example payload. It contains

  • The subscription group itself
  • Array of anomaly reports
  • A Report Object around all the anomalies
{
"subscriptionGroup": {
"id": 188059,
"name": "webhook",
"alerts": [
{
"id": 136062
}
],
"cron": "*/1 * * * * ?",
"specs": [
{
"type": "webhook",
"params": {
"url": "http://localhost:8080/internal/webhook"
}
}
]
},
"anomalyReports": [
{
"anomaly": {
"id": 188180,
"startTime": 1583020800000,
"endTime": 1588291200000,
"avgCurrentVal": 2.3475211E7,
"avgBaselineVal": 6.1570800760419734E7,
"score": 0.0,
"weight": 0.0,
"impactToGlobal": 0.0,
"sourceType": "ANOMALY_REPLAY",
"created": 1653463092111,
"notified": true,
"alert": {
"id": 188172
},
"metric": {
"name": "passenger_count"
},
"metadata": {
"dataset": {
"name": "us_monthly_air_passengers_simplified"
},
"metric": {
"name": "passenger_count"
}
}
},
"url": "http://localhost:7004/anomalies/188180",
"data": {
"metric": "passenger_count",
"startDateTime": "Mar 01, 2020 00:00",
"lift": "-61.87 %",
"feedback": "Not Resolved",
"anomalyId": "188180",
"anomalyURL": "http://localhost:7004/anomalies/",
"currentVal": "23,475,211",
"baselineVal": "61,570,800.76",
"dimensions": [],
"swi": "0.00 %",
"function": "us_monthly_passengers_simplified-holtwinters",
"funcDescription": "Sample description payload for testing",
"duration": "1,464 hours",
"endTime": "May 01, 2020 00:00",
"timezone": "UTC",
"anomalyType": "Deviation",
"properties": ""
}
}
],
"report": {
"startTime": "Sep 01, 2001 00:00",
"endTime": "May 01, 2020 00:00",
"reportGenerationTimeMillis": 1653464950589,
"dashboardHost": "http://localhost:7004",
"relatedEvents": [
{
"id": 3,
"name": "Related Holiday",
"type": "HOLIDAY",
"startTime": 1546310140005,
"endTime": 1546396540005,
"targetDimensionMap": {}
}
]
}
}

Integration with Notification endpoint to any other custom service using Webhook

Refer to this github link to get access to the code. Here is the code snippet:

def arrow(cur,base)
if ($base < $cur)
"⇑"
else if ($base > $cur)
"⇓"
else
"⇝"

[
for (.anomalyReports)
{
"markdown" : "---"+"\n "+
"### **"+ .data.function +"** \n "+
"### Metric : **"+ .data.metric+"** \n "+
"### Change : " + .data.lift + " " + arrow(.data.currentVal,.data.baselineVal) +"\n "+
"#### Start Time : " + fallback(.data.startTime,.data.startDateTime) + " " + .data.timezone + " Duration " + .data.duration +"\n "+
"#### Current Value : " + .data.currentVal +"\n "+
"#### Baseline Value : " + .data.baselineVal +"\n "+
"#### dimensions : " + string(.data.dimensions) +"\n "+
"**"+ .data.funcDescription +"** \n "+
"**[Anomaly URL](http://<hostname>/anomalies/" + .data.anomalyId +")** \n "+
"---"+"\n "
}

]