Skip to content

Commit d91c92f

Browse files
authored
Merge pull request duneanalytics#432 from duneanalytics/add-alerts
Add alerts
2 parents 0d214b8 + f0fefcc commit d91c92f

File tree

10 files changed

+208
-8
lines changed

10 files changed

+208
-8
lines changed

docs/app/.pages

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ nav:
88
- wand-llm.md
99
- upload-data.md
1010
- embeds.md
11-
- search.md
11+
- search.md
12+
- alerts.md

docs/app/alerts.md

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
---
2+
title: Alerts
3+
4+
---
5+
6+
**Alerts allow you to receive notifications based on any query!**
7+
8+
Alerts allows users to set notifications for a scheduled query. These notifications are triggered each time the query runs. Supported delivery methods include:
9+
10+
- **Email:** Multiple email addresses can be added.
11+
- **Webhooks:** Alerts can be sent to a specified callback URL, including Slack.
12+
13+
## Setup
14+
15+
### Accessing Alerts
16+
17+
<div style="position: relative; padding-bottom: calc(61.25000000000001% + 41px); height: 0;"><iframe src="https://demo.arcade.software/6IfAf55RjoFQ5OCax9Zj?embed" frameborder="0" loading="lazy" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;color-scheme: light;"></iframe></div>
18+
19+
To use Alerts, follow these steps:
20+
21+
1. Open a saved query that you own.
22+
2. Click the "Schedule" button.
23+
3. Configure the query schedule.
24+
4. Activate the Alerts option.
25+
5. Configure the alert delivery method.
26+
6. Save the schedule.
27+
7. Every time the query runs, the alert will be triggered.
28+
29+
30+
### Alert Timing
31+
32+
Alerts are triggered after query execution. Delays may occur due to factors like query complexity or system queues. Note that retry mechanisms for failed deliveries are not yet implemented.
33+
34+
!!! warning
35+
36+
Alerts are not recommended for time-sensitive or critical applications at this stage.
37+
38+
39+
40+
## Alert Content
41+
42+
### Email Alerts
43+
44+
Email alerts include screenshots of the visualizations you have defined. If you have defined no visualizations, we include a screenshot of the query results by default. Here's an example:
45+
46+
![Default email alert](./images/alerts/email_table.png)
47+
48+
If you have defined a visualization, we will include it instead of the table, like this:
49+
50+
![Email Alert with visualization](./images/alerts/email_viz.png)
51+
52+
53+
If your query contains multiple visualizations, or table visualizations (outside the default "Query results" table), they will all be included, such as here:
54+
55+
![Email Alert with multiple visualizations](./images/alerts/email_complex.png)
56+
57+
### Webhook Alerts
58+
59+
Webhook alerts adhere to the following schema:
60+
61+
```jsx
62+
{
63+
message: string,
64+
query_result: {
65+
execution_id: string;
66+
query_id: number;
67+
state: string;
68+
submitted_at: string;
69+
expires_at: string;
70+
execution_started_at: string;
71+
execution_ended_at: string;
72+
result: {
73+
data_uri: string;
74+
metadata: {
75+
column_names: string[];
76+
result_set_bytes: number;
77+
total_row_count: number;
78+
datapoint_count: number;
79+
pending_time_millis: number;
80+
execution_time_millis: number;
81+
};
82+
};
83+
},
84+
visualizations: [
85+
{
86+
title: string;
87+
image_url: string;
88+
}
89+
]
90+
}
91+
```
92+
93+
Here is an example corresponding to the last email example shared earlier:
94+
95+
```
96+
{
97+
"message": "Query ETH SMA alert was submitted for execution at Wed, 13 Dec 2023 13:42:40 GMT by your query schedule and it was successfully executed with a non empty result.\nYou can check its latest result here: https://dune.com/queries/3137182?utm_source=webhook&utm_campaign=alerts",
98+
"query_result": {
99+
"execution_id": "01HHHPMKG6NBY0B04A36TS3AQH",
100+
"query_id": 3137182,
101+
"state": "QUERY_STATE_COMPLETED",
102+
"submitted_at": "2023-12-13T13:42:40Z",
103+
"expires_at": "2024-03-12T13:42:48Z",
104+
"execution_started_at": "2023-12-13T13:42:40Z",
105+
"execution_ended_at": "2023-12-13T13:42:48Z",
106+
"result": {
107+
"data_uri": "https://api.dune.com/api/v1/execution/01HHHPMKG6NBY0B04A36TS3AQH/results",
108+
"metadata": {
109+
"column_names": [
110+
"day",
111+
"avg_price",
112+
"sma_20",
113+
"sma_50",
114+
"sma_100",
115+
"sma_200"
116+
],
117+
"result_set_bytes": 10710,
118+
"total_row_count": 91,
119+
"datapoint_count": 546,
120+
"pending_time_millis": 13,
121+
"execution_time_millis": 8038
122+
}
123+
}
124+
},
125+
"visualizations": [
126+
{
127+
"title": "SMA",
128+
"image_url": "https://prod-dune-media.s3.eu-west-1.amazonaws.com/screenshots/3137182/01HHHPMKG6NBY0B04A36TS3AQH/5232261.png"
129+
},
130+
{
131+
"title": "Counter",
132+
"image_url": "https://prod-dune-media.s3.eu-west-1.amazonaws.com/screenshots/3137182/01HHHPMKG6NBY0B04A36TS3AQH/5451006.png"
133+
},
134+
{
135+
"title": "Last days of data",
136+
"image_url": "https://prod-dune-media.s3.eu-west-1.amazonaws.com/screenshots/3137182/01HHHPMKG6NBY0B04A36TS3AQH/5451008.png"
137+
}
138+
]
139+
}
140+
```
141+
142+
Validation of the webhook format can be done at [Webhook.site](https://webhook.site/). You can easily test it out by triggering manual deliveries by clicking the Manual trigger link below the URL field.
143+
144+
## Integration with Third-Party Apps
145+
146+
### Slack Support
147+
148+
The webhook alert type supports posting directly to Slack. Users should:
149+
150+
1. Create a [Slack app](https://api.slack.com/apps) and activate "Incoming Webhooks."
151+
2. Paste the Slack hook URL into the Alert configuration.
152+
3. The help text below the field should indicate that a Slack URL has been detected:
153+
154+
![Slack Setup](./images/alerts/slack_setup.png)
155+
156+
Once saved, you will start receiving messages on Slack. Here is an example of how it looks:
157+
158+
![Slack message](./images/alerts/slack_hook.png)
159+
160+
### Zapier Integration
161+
162+
[Zapier](https://zapier.com/) is a third party solution that supports building integrations betwen different software solutions without writing any code. With it you can build advanced workflows that relay data between Dune and your favorite work tools.
163+
164+
We currently offer an experimental [Zapier app](https://zapier.com/developer/public-invite/194504/2174c6b998748b657f28dab4097f3e80/) to support connecting Dune with thousands of other tools via Zapier.
165+
166+
To set it up, follow these steps:
167+
168+
1. Accept the invite to use our private Zapier app via [this link](https://zapier.com/developer/public-invite/194504/2174c6b998748b657f28dab4097f3e80/).
169+
2. Create a new zap, with a [Webhook trigger](https://zapier.com/apps/webhook/integrations).
170+
3. Copy the webhook URL provided by Zapier's Webhook trigger, and paste it in the Dune webhook URL field.
171+
4. Now, on Zapier you can click Test to test that the webhook works.
172+
5. Trigger a manual hook request from the Alerts configuration form to test it out, and it should show up on Zapier.
173+
1. If you want to relay screenshots to other tools, the screenshots will be in the payload.
174+
2. If you want to relay query results, the Dune Zapier App includes an action to fetch a query's latest results by query id, which will allow you to easily fetch query results.
175+
176+
This is where you can trigger manual hook deliveries:
177+
178+
![Manual hook](./images/alerts/manual_hook.png)
179+
180+
Your setup on Zapier should look something like this:
181+
182+
![Zapier zap](./images/alerts/zapier_example.png)
183+
184+
## Known Issues and Solutions
185+
186+
1. **Manual Alert Triggering:** Currently, manual triggering is only available for webhooks.
187+
188+
1. We're planning to add it to Email and Slack. In the meantime, you can set your query on a 15-minute schedule for quicker testing.
189+
190+
2. **No results in webhook:** Instead of including query results in the callback, the webhook payload includes a URL to fetch the query's results in case you need to action on them.
191+
192+
1. We do not include datapoints in the hook callback in order to prevent unwanted credit spend on data exports.
193+
2. We're open to feedback on changing this behavior. If you have thoughts, let us know.
194+
195+
## Feedback
196+
197+
Feedback can be provided through the Alerts Beta Telegram channel.
198+
199+
[Join the channel](https://t.me/+bt5J1QlJ3_FhMDU0)
200+
201+
## Acknowledgement
202+
203+
Thank you to everyone that participated in our beta testing program. Your feedback has been essential for improving this feature.
204+
205+
---
335 KB
Loading
94 KB
Loading
191 KB
Loading
41.9 KB
Loading
105 KB
Loading
39.2 KB
Loading
243 KB
Loading

docs/app/upload-data.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,7 @@ You can query for your data in any query.
5757
Select * from dune.dune.dataset_energy_data
5858
```
5959

60-
To check whether the datatypes are correctly inferred, you can use the following query:
61-
62-
```sql
63-
SELECT * FROM information_schema.columns
64-
WHERE table_schema = 'dune' -- replace with your team name
65-
AND table_name = 'energy_data'; -- replace with your dataset name
66-
```
60+
To check whether the datatypes are correctly inferred, you can check the table details in the [data explorer](../app/query-editor/data-explorer.md).
6761

6862
## Updating data
6963

0 commit comments

Comments
 (0)