SQL Alerts notify the user whenever the result of a query is higher, lower, or equal to a predefined value. They're especially good for making sure nothing catastrophic has happened to the data pipeline.
Start by clicking on the "SQL Alerts" menu item in the header:
Once here, click the "Add New" button and define the alert!
In the SQL editor, define the query to be run. The alert's SQL must return a single value. Then, in the Condition section, enter a threshold on which to be alerted.
This alert will trigger an email if there are more than 5000 purchases in the last day:
Emails for alerts include the name of the alert, the value which triggered the email, the description of the alert, and the alert owner.
SQL Alerts can be configured to run either on an interval or at a scheduled time.
To run a SQL Alert on an interval, select the interval option and choose from every 10 minutes, 30 minutes, 1 hours, 4 hours, 12 hours, or 24 hours.
By selecting the ‘Schedule’ option, alerts can be set to run at a specific time in UTC.
Normally, SQL Alerts will trigger an email either if the set condition is met, or if the specified query returns an error. Common issues include syntax errors, database connection errors, queries timing out, or a table not existing during an ETL process. You can set the alert to not trigger error emails by checking the box next to 'Do not alert if query errors'.
The max ignored errors is the number of consecutive errored runs that will be ignored and not trigger an email. Here, two alert errors will be ignored, but the third will trigger an email that the alert SQL has errored out.
This setting does not automatically re-run the SQL Alert if it fails initially. Instead, the alert will wait to run the query again at the next scheduled time.
Periscope executes alert queries directly on the customer database selected in the dropdown. For customers using the Periscope Enterprise Plan, the query skips the cache and executes directly on the database to provide the most up-to-date results.
SQL Alerts can be disabled by turning off the "Alert Enabled" switch under the "Settings" header.
The number of rows returned by a SQL alerts's query is limited to 5000 by default. This can be adjusted by either entering a new number into the Limit Rows text box, or by writing a LIMIT or TOP clause into the query. Limits that are defined in the query or in the UI will be used when the SQL Alert query is run.
In the SQL Alert editor a query can return multiple columns and rows of data, but for an alert to successfully run the query must only return one value. If a LIMIT or TOP clause is defined in the query, the row limit defined in the UI will not be applied to the query.