SQL-first alerting system for data analysts
Project description
SQL Sentinel
SQL-first alerting for data analysts. Monitor business metrics and data quality using the SQL you already know.
# alerts.yaml — that's all you need
database:
url: "postgresql://user:pass@localhost/mydb"
alerts:
- name: "Daily Revenue Check"
query: |
SELECT
CASE WHEN SUM(revenue) < 10000 THEN 'ALERT' ELSE 'OK' END as status,
SUM(revenue) as actual_value,
10000 as threshold
FROM orders
WHERE order_date = CURRENT_DATE - 1
schedule: "0 9 * * *"
notify:
- channel: email
recipients: ["team@company.com"]
sqlsentinel validate alerts.yaml # Check config
sqlsentinel run alerts.yaml --dry-run # Test without sending notifications
sqlsentinel daemon alerts.yaml # Run on schedule
Installation
pip (recommended)
pip install sqlsentinel
Docker
docker pull sqlsentinel/sqlsentinel:latest
From source
git clone https://github.com/kyle-gehring/sqlsentinel.git
cd sqlsentinel
pip install .
Quick Start (5 minutes)
1. Create a config file
Create alerts.yaml with your database connection and alert definitions. Each alert is a SQL query that returns a status column with 'ALERT' or 'OK':
database:
url: "sqlite:///mydata.db" # Or postgresql://, mysql://, bigquery://, etc.
alerts:
- name: "Daily Revenue Check"
description: "Alert if yesterday's revenue is below $10,000"
query: |
SELECT
CASE WHEN SUM(revenue) < 10000 THEN 'ALERT' ELSE 'OK' END as status,
SUM(revenue) as actual_value,
10000 as threshold
FROM orders
WHERE order_date = CURRENT_DATE - 1
schedule: "0 9 * * *"
notify:
- channel: email
recipients: ["team@company.com"]
2. Validate and test
# Check your config is valid
sqlsentinel validate alerts.yaml
# Run alerts without sending notifications
sqlsentinel run alerts.yaml --dry-run
# Run a specific alert
sqlsentinel run alerts.yaml --alert "Daily Revenue Check" --dry-run
3. Run in production
# Start the daemon — runs alerts on their cron schedules
sqlsentinel daemon alerts.yaml
Or with Docker:
docker run -d \
-v $(pwd)/alerts.yaml:/app/config/alerts.yaml \
-e SMTP_HOST="smtp.gmail.com" \
-e SMTP_USER="alerts@company.com" \
-e SMTP_PASSWORD="your-app-password" \
sqlsentinel/sqlsentinel:latest
Query Contract
All alert queries must return a status column. Everything else is optional context:
| Column | Required | Description |
|---|---|---|
status |
Yes | 'ALERT' or 'OK' |
actual_value |
No | The metric value |
threshold |
No | The threshold that was exceeded |
| (any other) | No | Included in notification context |
Supported Databases
Via SQLAlchemy: PostgreSQL, MySQL/MariaDB, SQLite, SQL Server, Snowflake, BigQuery, Redshift, DuckDB
Notification Channels
- Email — SMTP with configurable templates
- Slack — Webhook integration
- Webhook — Generic HTTP POST for any service
CLI Reference
sqlsentinel validate <config> # Validate configuration
sqlsentinel run <config> [--alert NAME] [--dry-run] # Run alerts
sqlsentinel daemon <config> # Run on schedule
sqlsentinel history [--state-db URL] # View execution history
sqlsentinel status <config> [--state-db URL] # Show alert states
sqlsentinel silence <config> --alert NAME # Silence an alert
sqlsentinel unsilence <config> --alert NAME # Unsilence an alert
sqlsentinel healthcheck <config> # Check system health
sqlsentinel metrics # Prometheus metrics
sqlsentinel init <config> # Initialize state database
AI-First Design
SQL Sentinel works naturally with AI coding assistants like Claude Code. Instead of writing YAML by hand, describe what you want:
You: "I need an alert that checks if yesterday's revenue is below $10,000. Email me at team@company.com every morning at 9 AM."
Claude Code will:
- Generate the SQL query for your database
- Create the YAML configuration
- Validate the alert
- Test the database connection
- Set up the schedule
Common AI Tasks
- "Create an alert for daily revenue dropping below $10k"
- "Show me all my configured alerts"
- "Test the daily_revenue alert without sending notifications"
- "Silence the inventory_low alert for 2 hours"
- "What was the last execution result for my data quality alerts?"
- "Add a Slack notification to my existing revenue alert"
All of these work naturally with Claude Code — no MCP server needed. See AI Workflows Guide for more examples.
Set Up Your AI Assistant
Copy a template file into your project so your AI assistant understands SQL Sentinel:
# Claude Code
cp docs/ai-setup/CLAUDE.md /path/to/your/project/
# OpenAI Codex
cp docs/ai-setup/AGENTS.md /path/to/your/project/
# Google Gemini
cp docs/ai-setup/GEMINI.md /path/to/your/project/
# GitHub Copilot
cp docs/ai-setup/copilot-instructions.md /path/to/your/project/.github/
# Cursor
cp docs/ai-setup/.cursorrules /path/to/your/project/
See AI Setup Guide for details.
Examples
The examples/ directory contains ready-to-run configurations:
alerts.yaml— Basic alerts with SQLite (revenue, error rate, data freshness)alerts-multi-channel.yaml— Multi-channel notifications (email + Slack + webhook)bigquery-alerts.yaml— BigQuery-specific examplessample_data.db— Sample SQLite database for testing
Try it locally:
sqlsentinel validate examples/alerts.yaml
sqlsentinel run examples/alerts.yaml --dry-run
Documentation
- AI Workflows Guide — Using SQL Sentinel with Claude Code
- Docker Deployment — Production Docker setup
- Health Checks — Monitoring SQL Sentinel itself
- Prometheus Metrics — Metrics export reference
- Multi-Channel Notifications — Email, Slack, webhook setup
- Daemon Usage — Running as a background service
- BigQuery Setup — Google BigQuery configuration
- FAQ — Frequently asked questions
Contributing
See CONTRIBUTING.md for development setup, testing, and PR guidelines.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlsentinel-0.1.0.tar.gz.
File metadata
- Download URL: sqlsentinel-0.1.0.tar.gz
- Upload date:
- Size: 42.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14354be41d883536bba85d873e592566fe7c39a80299ca2090ed672413e94168
|
|
| MD5 |
3fa97e90c8f8098cfa0f705cb6e90c39
|
|
| BLAKE2b-256 |
cd1b0e87986368a603fe836f9aea47cf6e26e57e15e76a5876f45147ccc553fa
|
Provenance
The following attestation bundles were made for sqlsentinel-0.1.0.tar.gz:
Publisher:
publish.yml on kyle-gehring/sqlsentinel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlsentinel-0.1.0.tar.gz -
Subject digest:
14354be41d883536bba85d873e592566fe7c39a80299ca2090ed672413e94168 - Sigstore transparency entry: 993683861
- Sigstore integration time:
-
Permalink:
kyle-gehring/sqlsentinel@fafd00d6f3107ede57ffcaec94cae56a9437bf43 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kyle-gehring
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fafd00d6f3107ede57ffcaec94cae56a9437bf43 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sqlsentinel-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sqlsentinel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 55.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb2eee65009317e8c0aa99579451a3f6a6d526c1f6d24966586613e46b247c7d
|
|
| MD5 |
4271395b0e8b4429a083715e8510a3d8
|
|
| BLAKE2b-256 |
0af7bf30c208ea502a09e9e37888465dbbc33c6a3544860040e4d46f013f0c3c
|
Provenance
The following attestation bundles were made for sqlsentinel-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on kyle-gehring/sqlsentinel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlsentinel-0.1.0-py3-none-any.whl -
Subject digest:
fb2eee65009317e8c0aa99579451a3f6a6d526c1f6d24966586613e46b247c7d - Sigstore transparency entry: 993683930
- Sigstore integration time:
-
Permalink:
kyle-gehring/sqlsentinel@fafd00d6f3107ede57ffcaec94cae56a9437bf43 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kyle-gehring
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fafd00d6f3107ede57ffcaec94cae56a9437bf43 -
Trigger Event:
push
-
Statement type: