LogChef provides a powerful alerting system that continuously evaluates your log data against custom conditions. When thresholds are exceeded, alerts are sent directly via email (SMTP) and webhook notifications configured per alert.
The alerting system is designed for production use with built-in reliability features including retry logic, delivery failure tracking, and comprehensive error handling.
Understanding the Alert Flow
What you do in LogChef:
Create an alert with a condition or SQL query and threshold (e.g., “error count > 100”)
Select team members to notify and add webhook URLs in the alert form
Configure SMTP settings in Administration → System Settings → Alerts
What LogChef does:
Evaluates your query every X seconds (you set the frequency)
Builds an alert notification payload with labels, annotations, and context
Sends email notifications to the selected recipients
Posts JSON payloads to each configured webhook URL
Records delivery outcomes in alert history
Important to understand:
LogChef creates, evaluates, and delivers notifications
Email delivery uses SMTP settings configured by admins
Webhooks are defined per alert
Alert history shows when alerts fired and their delivery status
Quick Example
Scenario: You want to get notified on Slack when your API has more than 100 errors in 5 minutes.
In LogChef (using LogChefQL - the simple way):
Navigate to your team/source → Alerts
Click “New Alert”
Name: “High API Errors”
Filter condition: severity = "ERROR"
Threshold: Greater than 100
Lookback: 5 minutes (time filter is auto-applied)
Frequency: Every 60 seconds
Save
The generated SQL will be: SELECT count(*) as value FROM logs WHERE (severity = 'ERROR') AND timestamp >= now() - toIntervalSecond(300)
Result: Every minute, LogChef checks error count. If > 100, it sends emails to the selected team members and posts the webhook payload. You can see all firings in LogChef’s alert history.
Email & Webhook Delivery
Send notifications directly via SMTP email and webhook endpoints.
Simple & Advanced Modes
Use LogChefQL for simple filter conditions, or write raw ClickHouse SQL for complex queries.
Delivery Guarantees
Automatic retry logic with exponential backoff ensures notifications are delivered reliably.
Rich Metadata
Alerts include team and source names, custom labels, annotations, and direct links to the web UI.
How it Works
LogChef’s alert manager runs in the background, continuously evaluating active alerts at the configured interval (default: 1 minute). When an alert’s SQL query returns a value that exceeds the threshold, the alert fires and LogChef sends email and webhook notifications with full context including labels, annotations, and metadata.
Alert Lifecycle
Evaluation: Alert SQL query runs against ClickHouse
Threshold Check: Result is compared against configured threshold
Triggered: If threshold is met, alert fires and notification payload is built
Delivered: Email notifications are sent to selected recipients
Webhooked: JSON payloads are posted to configured webhook URLs
Resolved: When conditions clear, a resolution notification is sent
Creating Alerts
Query Modes
LogChef supports two ways to define alert conditions:
LogChefQL Mode (Recommended)
The simplest way to create alerts. Write a filter condition and LogChef generates the SQL automatically:
Filter Condition: Simple expressions like severity = "ERROR" or status_code >= 500
Aggregate Function: Choose count, sum, avg, min, or max
Auto Time Filter: Lookback period is automatically applied—no manual time filters needed
Live Preview: See the generated SQL before saving
Example conditions:
severity = "ERROR"
severity = "ERROR" and service = "api"
status_code >= 500
response_time > 1000
message ~ "timeout"
SQL Mode (Advanced)
For complex queries, switch to SQL mode and write raw ClickHouse SQL:
Full control over the query
Access to all ClickHouse functions
Must return a single numeric value as value
Basic Alert Configuration
Every alert requires the following components:
Name: Human-readable identifier for the alert
Description: Optional context about what the alert monitors
Severity: info, warning, or critical
Query: LogChefQL condition or ClickHouse SQL
Threshold: Value and operator (>, >=, <, <=, ==, !=)
Frequency: How often to evaluate the alert (in seconds)
Lookback Window: Time range for the query to analyze
Example Alerts
High Error Rate
Monitor when error log count exceeds acceptable levels.
Threshold: Greater than or equal to 95 | Frequency: 60 seconds | Severity: Critical
Configuration
Admin Settings UI
Alerting is configured through the Administration → System Settings → Alerts tab in the web interface. This provides a user-friendly way to manage all alert settings without editing configuration files.
Available Settings:
Enabled: Toggle alert evaluation on/off
SMTP Host: Email server hostname
SMTP Port: Email server port
SMTP Username: SMTP auth username (optional)
SMTP Password: SMTP auth password (optional)
SMTP From: From address for alert emails
SMTP Reply-To: Reply-To address (optional)
SMTP Security: none, starttls, or tls
Evaluation Interval: How often to evaluate all alerts
Default Lookback: Default time range for alert queries
History Limit: Number of historical events to keep per alert
External URL: Backend URL for API access
Frontend URL: Frontend URL for web UI links in alert notifications
Recipients and webhook URLs are configured per alert. In the alert form, select team members to notify and add one or more webhook URLs for integrations like Slack, PagerDuty, or custom endpoints.
Initial Configuration (First Boot)
On first boot, you can optionally seed alert settings from config.toml. After first boot, all changes must be made via the Admin Settings UI:
[alerts]
# Enable alert evaluation and delivery
enabled = true
# How often to evaluate all alerts (default: 1 minute)
evaluation_interval = "1m"
# Default lookback window if not specified in alert (default: 5 minutes)
default_lookback = "5m"
# Maximum alert history entries to keep per alert (default: 100)
history_limit = 100
# SMTP configuration for email delivery
smtp_host = "smtp.example.com"
smtp_port = 587
smtp_username = ""
smtp_password = ""
smtp_from = "alerts@example.com"
smtp_reply_to = ""
smtp_security = "starttls"
# Backend URL for API access (used for fallback)
external_url = "http://localhost:8125"
# Frontend URL for web UI generator links
frontend_url = "http://localhost:5173"
# HTTP request timeout for alert delivery
request_timeout = "5s"
# Skip TLS certificate verification (for development only)
tls_insecure_skip_verify = false
Note: After first boot, changes to [alerts] in config.toml are ignored. Use the Admin Settings UI to modify alert configuration.
Alert Labels and Annotations
Default Labels
Every alert includes these labels automatically:
alertname: Name of the alert
alert_id: Unique alert identifier
severity: Alert severity level
status: Current status (triggered or resolved)
team: Human-readable team name
team_id: Numeric team identifier
source: Human-readable source name
source_id: Numeric source identifier
Custom Labels
Add custom labels to categorize and route alerts:
{
"env": "production",
"service": "payment-api",
"region": "us-east-1",
"component": "database"
}
These labels are included in webhook payloads and email notifications for filtering and routing on the receiver side.
Annotations
Annotations provide additional context that doesn’t affect routing:
description: Alert description text
query: The SQL query used for evaluation
threshold: Threshold value and operator
value: Actual value that triggered the alert
frequency_seconds: Evaluation frequency
lookback_seconds: Query lookback window
Custom annotations can be added for runbooks, dashboards, or documentation links: