Cannot Get Query Results in SQL Alerts
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 10:25 PM
Example Query:
select name, date from errors;
Now i want to trigger an alert if count is greater than 1, and a notification should be sent to slack with output rows (name and date values). Even if i use {{QUERY_RESULT_ROWS}}, it only gives value after count is applied.
Is there any way to get the actual rows using Alerts?
Labels:
- Labels:
-
Workflows
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2024 09:34 AM
Note I have not tried this myself, but can you try the following and let me know if it helps:
- Create the query, so SELECT name, date FROM errors;
- Set up the alert. Set the condition to trigger the alert when the count of rows is greater than 1.
- Create a separate query that formats the result as a single string.
SELECT CONCAT_WS(', ', COLLECT_LIST(CONCAT(name, ' - ', date))) AS formatted_result FROM errors WHERE <your_condition>;
- Use this query in your alert to trigger the notification. The formatted_result should contain the concatenated rows.
- Send notification to Slack. In the alert settings, you can use the formatted_result to include the actual rows in the message.