/api/alerts, as described below.
API documentation is provided in your environment at this link:
https://<Self-Service Analytics-URL>/composer/swagger-ui.html.
Create an Alert Definition - Alerts API
Use alerts to alert yourself and other users when a metric reaches a specified threshold. Use the alerts endpoints to create alert definitions. These definitions describe an alert condition, determine a schedule to evaluate the alert condition, and how notifications are handled when an alert condition is met. See Create an Alert Definition to create alerts using the User Interface. Use the endpoint/api/alerts to manage (list, create, update, and delete) alert definitions.
API documentation is provided in your environment at this link:
https://<Self-Service Analytics-URL>/composer/swagger-ui.html.
Alert Definition Object Structure
Alert definitions are created by submitting aPOST api/alerts endpoint with a request body that uses the object structure defined here.
Here is a sample of the general object structure required to create an alert definition:
| Object | Specifies |
|---|---|
name | The name of the alert definition. |
description | A description of the alert definition. |
enabled | Whether or not the definition is enabled. A value of true indicates that it is enabled; false indicates that it is not. If an alert is not enabled, it is not scheduled at all. |
schedule | The frequency by which the alert condition in the definition should be evaluated. Valid values are ONCE, MONTHLY, WEEKLY, and DAILY. Each of these values requires additional fields to more specifically identify when the alert condition should be evaluated:
Example: |
condition | The alert condition that should be evaluated. The alert condition requires the following fields:
|
notification | The notification information for the alert. The notification structure is fully described in detail in Alert Definition Notification Structure. It includes a notification type (only EMAIL is currently supported), a subject for the email message, text for the body of the email message, and recipient information. |
Alert Definition Data Query Structures
The data query used in an alert definition always specifies a filter condition to be evaluated. Different kinds of data query conditions can be specified: raw, KPI, single group by, or multigroup by queries. Simple filters and aggregate filters are used to establish these query conditions. This section describes and provides examples for the filter structure and the structures for all query types.- Simple Filters
- Aggregate Filters
- Raw Data Query Conditions
- KPI Data Query Conditions
- Single Group By Queries
- Multigroup By Queries
Simple Filters
Because alert conditions are checked periodically, filter conditions must be set properly, especially if the queried data is limited to a dynamic timeframe.
Aggregate Filters
Aggregate filters define thresholds using theaggregateFilters object in the following structure. Usually a single threshold is defined, but more complex aggregate filters can be specified. The following aggregate filter example searches for groups (for example, product categories) with 1 to 1000 sales records in which the sum of the sales price fell between $2 and $700,000.
aggregateFilters query structure.
Raw Data Query Conditions
A raw data query condition supports only simple filters. The following sample raw query condition searches for sales records with sale dates that occurred in the last month and with prices that equal or exceed $1,000,000.00. When records are found meeting these conditions, and alert notification is sent.KPI Data Query Conditions
A KPI query condition is a single-dimension query, without aggregations. Filters can be used to reduce the data to be evaluated. The threshold is defined by aggregate filters. The following sample KPI query condition searches for sales records from the state of Alabama with sale dates that occurred in the last month and with total planned sales between $1 and $3,035.00. If no records can be found that meet these conditions, an alert notification is sent.Single Group By Queries
Single group by queries are similar to KPI data queries, but add one aggregation. Filters can be used to reduce the data to be evaluated. The threshold is defined by aggregate filters. The window attribute may be defined for the dimension section. But it does not affect the query execution logic. The following sample single group by query condition searches for sales records from the state of Alabama, aggregated by product group, with sale dates that occurred in the last month and with total planned sales between $1 and $3,035.00. If no records can be found that meet these conditions, an alert notification is sent.Multigroup By Queries
Multigroup by queries are the same as Single Group By queries, except that they allow for more than one aggregation.Top of the Top sorting is not supported; only simple sorting is supported. We recommend that no sorting be specified at all.
Alert Definition Notification Structure
Here is a sample of the general object structure for the notification object of an alert definition:| Parameter | Specifies |
|---|---|
notificationType | The notification type. Currently only EMAIL is supported. |
subject | The subject of the notification email. |
body | The body text of the notification email. |
recipients | The users who should be notified. Users must be defined in your environment and all user definitions must have email addresses provided in their user definition. See Add Users. Use the following field pairs to define the recipients for the alert notification:
Repeat user field pairs, as needed, to alert more than one person. |
sendtoMe | Whether or not the alert notifications should be sent to the author of the alert definition. Specify true (send notifications to the author) or false (do not send notifications to the author).You can elect to send alert notifications only to the author of the alert definition. To do this, eliminate the field pairs in the recipients list and replace it with sendToMe set to true. |