https://github.com/cowprotocol/dune-alerts
A general purpose tool for generating Slack Alerts via query results from Dune Analytics
https://github.com/cowprotocol/dune-alerts
alerting dune-analytics hacktoberfest monitoring-tool slack-api slack-bot
Last synced: about 1 year ago
JSON representation
A general purpose tool for generating Slack Alerts via query results from Dune Analytics
- Host: GitHub
- URL: https://github.com/cowprotocol/dune-alerts
- Owner: cowprotocol
- Created: 2022-07-13T07:20:56.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-20T09:15:14.000Z (over 1 year ago)
- Last Synced: 2025-04-12T23:13:53.944Z (about 1 year ago)
- Topics: alerting, dune-analytics, hacktoberfest, monitoring-tool, slack-api, slack-bot
- Language: Python
- Homepage:
- Size: 79.1 KB
- Stars: 18
- Watchers: 6
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Query Monitor / Dune Alerts
This package combines both [DuneAPI](https://pypi.org/project/duneapi/)
and [SlackClient](https://pypi.org/project/slackclient/) in a way that can send alerts
in slack based on dune query
results.
To run this monitoring system will require the following steps:
1. An account on [Dune Analytics](https://dune.com) and
a [query](https://dune.com/queries/857522) you would like to
monitor.
2. An existing slack bot ([Create a Slack App](https://api.slack.com/apps))
To run the query monitor (for a single query) you will need to provide Dune credentials
and Slack app details.
Namely, the environment variables supplied in the [sample env file](.env.sample).
## Query Monitor from Configuration
Query Monitor objects are loaded from a yaml configuration file taking the following
form:
```yaml
name: Name of your Query
id: DUNE_QUERY_ID
window: (This is Optional)
offset: how far in hours back in time from datetime.now()
length: time interval length
parameters:
- key: param1
type: number
value: 100
- key: param2
type: text
value: example
```
where `DUNE_QUERY_ID` is found in the url of your existing query.
Concretely, it is the integer at the end of this url https://dune.com/queries/857522.
For more examples on query parameter configuration, checkout our test
examples [./tests/data](./tests/data/)
With all the configuration in place, then you can run the alerter with
```shell
python -m src.slackbot --query-config QUERY_CONFIG_PATH
```
where `QUERY_CONFIG_PATH` is a filepath to the yaml file containing your query
configuration.
This will load the query details, refresh the query with given parameters, fetch the
results and send an alert to the
configured Slack channel if warranted.
## Run with Docker
From the root of this project, assuming you have a .env file with dune and slack
credentials and a query
configuration `config.yaml`
```shell
# build
docker build -t slackbot .
docker run -v ${PWD}/config.yaml:/app/config.yaml --env-file .env slackbot --query-config config.yaml
```
```shell
docker run \
-v ${PWD}/:/app/cfg \
--env-file .env \
ghcr.io/cowprotocol/dune-alerts \
--query-config cfg
```