Skip to content

Example code for a tutorial for sending Slack alerts based on market data streamed to QuestDB

Notifications You must be signed in to change notification settings

questdb/questdb-slack-grafana-alerts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuestDB, Grafana, Slack alerts tutorial

This repository contains the example code for a tutorial about how to send alerts to Slack based on changes in market data streamed to QuestDB. Stock prices are fetched from the IexFinance API using the iexfinance Python package, streamed into QuestDB, a time series database, and alerts are set up in Grafana based on the metrics we care about.

Prerequisites

Structure

  • ./docker-compose.yml: starts QuestDB and Grafana
  • ./python/: holds Python files used in the tutorial:
    • mock_stock_data_example.py: generate mock data
    • stock_data_TSLA_example.py: polls IexFinance API and publishes records to QuestDB
    • .env file for storing our API key

Getting started

  1. Obtain an API key from IexFinance console

  2. In the ./python directory, create a file named .env

  3. Place the API key in this file in the following format:

    API_KEY=ncp2syw...
    
  4. Run docker compose:

    docker-compose up
    

The following services are now running:

  • QuestDB web console on port 9000
  • Grafana for visualizing time series data in QuestDB on port 3000

Python Setup

Install the necessary packages:

pip install -r requirements.txt

Poll the IexFinance API and send Tesla prices to QuestDB

cd python
python stock_data_TSLA_example.py

(Optional) Run the script to send mock API data to QuestDB:

cd python
python mock_stock_data_example.py

About

Example code for a tutorial for sending Slack alerts based on market data streamed to QuestDB

Topics

Resources

Stars

Watchers

Forks

Languages