Giter Site home page Giter Site logo

price-oracle-monitor's Introduction

Crypto Chemistry Price Oracle Monitor (CC-POM)

CC-POM aims to make monitoring price oracle misses easier by monitoring set addresses and alerting validators over Discord or Pagerduty

Supported Chains

Currently only Kujira is supported at this time.

Usage

The easiest way to run this is using docker-compose.

Docker-Compose

Clone the repository

git clone https://github.com/Crypto-Chemistry/price-oracle-monitor.git
cd price-oracle-monitor

Move example.docker-compose.yml to docker-compose.yml

mv example.docker-compose.yml docker-compose.yml

Edit docker-compose.yml and modify the variables. After the -a flag, a list of space-separated addresses to monitor should be provided. These do not need to belong to the same chain. After the -w flag, add the Discord webhook for the channel that you want to receive missed vote notifications on.

Example docker-compose.yml command segement:

command: "price_oracle_monitor.py \
              -a kujiravaloper.... \
              -w https://discord.com/api/webhooks/.... \
              -t 100"

Build the image

docker-compose build --no-cache

Run the application (It acts as a one-shot similar to Restake. To configure it as a repeated service, see Configuring a Price Oracle Monitor Service)

docker-compose run price_oracle_monitor

Running from source

Running this application from source is a bit more work to set up reliably and comes with additional requirements.

Python 3.10 or greater must be installed for this function properly. However, it has only been tested on Python 3.10.5 so far.

Clone the repository

git clone https://github.com/Crypto-Chemistry/price-oracle-monitor.git

Switch to the repo directory

cd price-oracle-monitor

Pull down the library dependencies

pip3 install -r requirements.txt

Run the price_oracle_monitor.py script with the required arguments

python3 price_oracle_monitor.py -a address1 address2 -w discord_webhook_url

Example command:

python3 price_oracle_monitor.py -a kujiravaloper... \
                                -w https://discord.com/api/webhooks/... \
                                -t 50

Update Instructions

To update to a newer version navigate to where the repo is cloned and run the following commands

git fetch --all
git pull

If using the Docker Compose method to run the application, make sure to force rebuild the image:

docker-compose kill
docker-compose build --no-cache

If running from source, make sure to reinstall the requirements.txt file in case new dependencies have been added:

pip3 install -r requirements.txt

Configuring a Price Oracle Monitor Service

To configure CC-POM as a service, first create a service file.

sudo nano /etc/systemd/system/cc-pom.service

Copy the following contents into the cc-pom.service file, replacing the WorkingDirectory variable with the path to where the repo is cloned.

[Unit]
Description=Price Oracle Monitoring Service
Requires=docker.service
After=docker.service

[Service]
Type=oneshot
WorkingDirectory=/path/to/cc-pom
ExecStart=/usr/bin/docker-compose run price_oracle_monitor

[Install]
WantedBy=multi-user.target

Run the following commands to start and enable the service:

sudo systemctl enable /etc/systemd/system/cc-pom.service
sudo systemctl start /etc/systemd/system/cc-pom.service

Available Parameters

Parameter Type Required Description
-a,--addresses String or multiple strings Yes Addresses to monitor
-d,--discord None No Enable Discord notification ('DISCORD_WEBHOOK' must be set as an environment varible to the webhook URL)
-f,--frequency Float No The frequency in minutes that CCPOM checks the API for new misses
-k,--key String No PagerDuty API Key (enables PagerDuty notifications)
-l,--lcd_endpoint String or multiple strings No API Endpoints to query
-p,--pagerduty None No Enables PagerDuty Notifications ('PD_API_KEY' must be set as an environment variable to the API Key)
-t,--threshold Int Yes Threshold for misses prior to alerting
-u,--userid String No Discord User by UUID to tag in alerts
-v,--verbose None No Enable verbose output
-w,--webhook String No Discord Webhook to send alerts to (enables Discord notifications)
--delay Int No Time between repeated notifications in minutes (default 30 minutes)

Examples

Send PagerDuty and Discord Alerts with environment variables set

python3 price_oracle_monitor.py -a kujiravaloper... \
                                -d \
                                -p \
                                -t 50

Send PagerDuty and Discord Alerts without environment variables set

python3 price_oracle_monitor.py -a kujiravaloper... \
                                -w "discord_webhook_url_here" \
                                -k "pagerduty_eventsv2_key_here" \
                                -t 50

Send PagerDuty and Discord Alerts without environment variables set, tag a user in the Discord notification, and delay repeated notifications for 3 hours per notification

python3 price_oracle_monitor.py -a kujiravaloper... \
                                -w "discord_webhook_url_here" \
                                -k "pagerduty_eventsv2_key_here" \
                                -u "123456789123456789" \
                                --delay 180 \
                                -t 50

Example Discord Notifications

Discord miss notification with tagged user Discord rpc alert with tagged user

price-oracle-monitor's People

Contributors

relyte avatar co8 avatar

Stargazers

Mehmet Köl Tiğin avatar Nodeist avatar  avatar

Watchers

GeoNodes avatar

price-oracle-monitor's Issues

feat: Add unit tests

Unit tests need to be added as the application grows and becomes more complex.

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.