Git Product home page Git Product logo

dune-alerts's Introduction

Query Monitor / Dune Alerts

This package combines both DuneAPI and 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 and a query you would like to monitor.
  2. An existing slack bot (Create a Slack App)

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.

Query Monitor from Configuration

Query Monitor objects are loaded from a yaml configuration file taking the following form:

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

With all the configuration in place, then you can run the alerter with

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

# build
docker build -t slackbot .
docker run -v ${PWD}/config.yaml:/app/config.yaml --env-file .env slackbot --query-config config.yaml
docker run \
    -v ${PWD}/<CONFIG_FILE>:/app/cfg \
     --env-file .env \
     ghcr.io/cowprotocol/dune-alerts \
     --query-config cfg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.