Alerta is a scalable, multi-technology alert management system that consolidates alerts from various monitoring tools. It provides alert deduplication, correlation, enrichment, and flexible routing with a modern web UI and API.
| File/Directory | Path | Purpose |
|---|---|---|
| Server config | /etc/alertad.conf |
Alerta server configuration |
| API config | /etc/alerta/api.conf |
Alerta API configuration |
| Web config | /usr/share/alerta/config.js |
Alerta web UI configuration |
| Plugins | /etc/alerta/plugins/ |
Plugin configurations |
| Rules | /etc/alerta/rules/ |
Alert routing rules |
| Database | /var/lib/alerta/ |
Database files (SQLite) |
| Logs | /var/log/alerta/ |
Alerta log files |
| Systemd | /etc/systemd/system/alertad.service |
Service definition |
| WSGI | /etc/alerta/wsgi.py |
WSGI application entry |
| Environment | /etc/alerta/alerta.env |
Environment variables |
# /etc/alertad.conf
# ========================
# Basic Settings
# ========================
# Base URL for the API
BASE_URL = 'https://alerta.example.com'
# Secret key for signing tokens
SECRET_KEY = 'your-super-secret-key-change-this-in-production'
# Database configuration
DATABASE_URL = 'postgresql://alerta:AlertaPassword123!@localhost/alerta'
# For SQLite (development only)
# DATABASE_URL = 'sqlite:////var/lib/alerta/alerta.db'
# Database connection pool settings
DATABASE_CONNECTION_POOL_SIZE = 10
DATABASE_CONNECTION_POOL_RECYCLE = 3600
# ========================
# Authentication
# ========================
# Authentication provider
AUTH_REQUIRED = True
AUTH_PROVIDER = 'basic' # basic, ldap, oidc, github, gitlab, google, saml2
# Allow user signup
ALLOW_SIGNUP = False
# Admin users
ADMIN_USERS = ['admin@example.com']
# User roles
USER_ROLES = ['user']
DEFAULT_USER_ROLES = ['user']
# Password policy
PASSWORD_MIN_LENGTH = 8
PASSWORD_REQUIRE_UPPERCASE = True
PASSWORD_REQUIRE_LOWERCASE = True
PASSWORD_REQUIRE_DIGIT = True
PASSWORD_REQUIRE_SPECIAL = False
# Session settings
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
PERMANENT_SESSION_LIFETIME = 86400 # 24 hours
# Token settings
TOKEN_EXPIRE_DAYS = 14
API_KEY_EXPIRE_DAYS = 365
# ========================
# LDAP Authentication
# ========================
LDAP_URL = 'ldap://ldap.example.com'
LDAP_BIND_DN = 'cn=admin,dc=example,dc=com'
LDAP_BIND_PASSWORD = 'LdapPassword123!'
LDAP_USER_BASE_DN = 'ou=users,dc=example,dc=com'
LDAP_USER_NAME_ATTR = 'uid'
LDAP_USER_EMAIL_ATTR = 'mail'
LDAP_GROUP_BASE_DN = 'ou=groups,dc=example,dc=com'
LDAP_GROUP_NAME_ATTR = 'cn'
LDAP_GROUP_MEMBER_ATTR = 'member'
LDAP_ADMIN_GROUP = 'alerta-admins'
LDAP_USER_GROUP = 'alerta-users'
LDAP_DOMAINS = {
'example.com': 'ldap'
}
# ========================
# OIDC Authentication
# ========================
OIDC_AUTH_URL = 'https://auth.example.com/oauth/authorize'
OIDC_TOKEN_URL = 'https://auth.example.com/oauth/token'
OIDC_USER_INFO_URL = 'https://auth.example.com/oauth/userinfo'
OIDC_CLIENT_ID = 'alerta-client'
OIDC_CLIENT_SECRET = 'oidc-client-secret'
OIDC_REDIRECT_URI = 'https://alerta.example.com/auth'
OIDC_SCOPE = ['openid', 'profile', 'email']
OIDC_CUSTOM_CLAIMS = {
'roles': {
'admin': ['admin'],
'user': ['user']
}
}
# ========================
# CORS Settings
# ========================
CORS_ORIGINS = [
'https://alerta.example.com',
'https://monitoring.example.com'
]
CORS_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']
CORS_ALLOW_HEADERS = ['Content-Type', 'Authorization']
CORS_EXPOSE_HEADERS = ['X-Total-Count', 'X-Page-Count']
CORS_SUPPORTS_CREDENTIALS = True
# ========================
# Alert Settings
# ========================
# Default severity levels
SEVERITY_MAP = {
'security': 0,
'critical': 1,
'major': 2,
'minor': 3,
'warning': 4,
'indeterminate': 5,
'informational': 6,
'normal': 7,
'ok': 7,
'cleared': 7,
'debug': 8,
'trace': 9,
'unknown': 10
}
DEFAULT_NORMAL_SEVERITY = 'normal'
DEFAULT_PREVIOUS_SEVERITY = 'indeterminate'
# Alert timeout
ALERT_TIMEOUT = 86400 # 24 hours
# Heartbeat timeout
HEARTBEAT_TIMEOUT = 120 # 2 minutes
# Maximum alert body length
MAX_ALERT_BODY_LENGTH = 65535
# ========================
# Blackout Periods
# ========================
# Enable blackout periods
BLACKOUT_DURATION = 3600 # 1 hour default
# ========================
# Escalation
# ========================
AUTO_REFRESH_INTERVAL = 5000 # 5 seconds
DEFAULT_PAGE_SIZE = 50
# ========================
# Email Settings
# ========================
SMTP_HOST = 'smtp.example.com'
SMTP_PORT = 587
SMTP_STARTTLS = True
SMTP_USERNAME = 'alerta@example.com'
SMTP_PASSWORD = 'EmailPassword123!'
SMTP_FROM = 'alerta@example.com'
EMAIL_VERIFICATION = False
MAIL_LOCALHOST = 'localhost'
# ========================
# Webhook Settings
# ========================
WEBHOOK_URLS = [
'https://hooks.slack.com/services/XXX/YYY/ZZZ',
'https://discord.com/api/webhooks/XXX/YYY'
]
# ========================
# Logging
# ========================
LOG_FILE = '/var/log/alerta/alertad.log'
LOG_MAX_BYTES = 10485760 # 10MB
LOG_BACKUP_COUNT = 5
LOG_FORMAT = 'simple'
LOG_LEVEL = 'INFO'
# ========================
# Plugins
# ========================
PLUGINS = [
'reject',
'blackout',
'enhance',
'normalise',
'email',
'slack',
'pagerduty',
'opsgenie',
'webhook',
'prometheus',
'heartbeat',
'forwarder'
]
# Plugin-specific settings
SLACK_API_KEY = 'xoxb-your-slack-bot-token'
SLACK_CHANNEL = '#alerts'
PAGERDUTY_SERVICE_KEY = 'your-pagerduty-service-key'
OPSGENIE_API_KEY = 'your-opsgenie-api-key'
# ========================
# Rate Limiting
# ========================
RATE_LIMIT_ENABLED = True
RATE_LIMIT_REQUESTS = 100
RATE_LIMIT_EXPIRES = 60 # 1 minute
# ========================
# Metrics
# ========================
METRICS_ENABLED = True
METRICS_ENDPOINT = '/metrics'
PROMETHEUS_NAMESPACE = 'alerta'
# ========================
# Housekeeping
# ========================
HOUSEKEEPING_INTERVAL = 60 # 1 minute
INACTIVE_THRESHOLD = 86400 # 24 hours
DELETE_EXPIRED_AFTER = 1209600 # 14 days
DELETE_INFO_AFTER = 86400 # 1 day
# /etc/alerta/api.conf
# API-specific configuration
DEBUG = False
TESTING = False
# Database
DATABASE_URL = 'postgresql://alerta:AlertaPassword123!@localhost/alerta'
# Authentication
AUTH_REQUIRED = True
AUTH_PROVIDER = 'basic'
SECRET_KEY = 'your-api-secret-key'
# CORS
CORS_ORIGINS = ['https://alerta.example.com']
# Logging
LOG_FILE = '/var/log/alerta/api.log'
LOG_LEVEL = 'INFO'
# Rate limiting
RATE_LIMIT_ENABLED = True
RATE_LIMIT_REQUESTS = 200
RATE_LIMIT_EXPIRES = 60
// /usr/share/alerta/config.js
'use strict';
angular.module('config', [])
.constant('config', {
'endpoint': 'https://alerta.example.com/api',
'provider': 'basic',
'oauth2_client_id': 'alerta-web-client',
'oauth2_authorize_url': 'https://auth.example.com/oauth/authorize',
'oauth2_token_url': 'https://auth.example.com/oauth/token',
'oauth2_redirect_uri': 'https://alerta.example.com/auth',
'oauth2_scope': 'openid profile email',
// Base URL
'base_url': '/api',
// Refresh interval
'refresh_interval': 5000,
// Time format
'time_format': 'HH:mm:ss',
'date_format': 'YYYY-MM-DD',
'long_date_format': 'YYYY-MM-DD HH:mm:ss.SSS',
// Severity colors
'colors': {
'severity': {
'security': '#000000',
'critical': '#E74C3C',
'major': '#E67E22',
'minor': '#F1C40F',
'warning': '#1E88E5',
'indeterminate': '#9B59B6',
'informational': '#00796A',
'normal': '#5CB85C',
'ok': '#5CB85C',
'cleared': '#5CB85C',
'debug': '#757575',
'trace': '#757575',
'unknown': '#525252'
},
'text': 'black'
},
// Features
'features': {
'email': true,
'slack': true,
'pagerduty': true,
'opsgenie': true,
'webhook': true,
'prometheus': true
},
// Audio
'audio': {
'enabled': true,
'new': 'https://raw.githubusercontent.com/alerta/alerta/master/alerta/contrib/audio/alerta-new.wav',
'open': 'https://raw.githubusercontent.com/alerta/alerta/master/alerta/contrib/audio/alerta-open.wav',
'closed': 'https://raw.githubusercontent.com/alerta/alerta/master/alerta/contrib/audio/alerta-closed.wav'
},
// Columns
'columns': [
{ 'name': 'severity', 'show': true },
{ 'name': 'status', 'show': true },
{ 'name': 'lastReceiveTime', 'show': true },
{ 'name': 'environment', 'show': true },
{ 'name': 'service', 'show': true },
{ 'name': 'group', 'show': true },
{ 'name': 'text', 'show': true },
{ 'name': 'tags', 'show': true },
{ 'name': 'attributes', 'show': false },
{ 'name': 'timeout', 'show': false },
{ 'name': 'type', 'show': false },
{ 'name': 'duplicateCount', 'show': true },
{ 'name': 'repeat', 'show': false },
{ 'name': 'trendIndication', 'show': false }
],
// Sortable columns
'sorting': {
'reverse': true,
'field': 'lastReceiveTime'
},
// Filter
'filter': {
'environment': ['Production', 'Development'],
'status': ['open', 'ack']
},
// Actions
'actions': [
{
'name': 'Acknowledge',
'url': '/actions/ack'
},
{
'name': 'Close',
'url': '/actions/close'
},
{
'name': 'Shelve',
'url': '/actions/shelve'
}
]
});
# /etc/alerta/rules.py
# Alert routing rules
ROUTING_RULES = [
{
'name': 'Critical to PagerDuty',
'match': {
'severity': 'critical',
'environment': 'Production'
},
'actions': ['pagerduty']
},
{
'name': 'Security Alerts',
'match': {
'severity': 'security'
},
'actions': ['slack', 'email'],
'attributes': {
'priority': 'high'
}
},
{
'name': 'Development Warnings',
'match': {
'severity': 'warning',
'environment': 'Development'
},
'actions': ['slack'],
'suppress': True
},
{
'name': 'Database Alerts',
'match': {
'group': 'Database'
},
'actions': ['email'],
'attributes': {
'team': 'dba'
}
},
{
'name': 'Network Alerts',
'match': {
'group': 'Network'
},
'actions': ['slack'],
'attributes': {
'team': 'network'
}
}
]
# Pre-receive hooks
PRE_RECEIVE_HOOKS = [
{
'name': 'Add Timestamp',
'function': 'add_timestamp'
},
{
'name': 'Normalize Severity',
'function': 'normalize_severity'
},
{
'name': 'Enrich from CMDB',
'function': 'enrich_from_cmdb'
}
]
# Post-receive hooks
POST_RECEIVE_HOOKS = [
{
'name': 'Send to Slack',
'function': 'send_slack'
},
{
'name': 'Forward to Prometheus',
'function': 'forward_prometheus'
}
]
# /etc/alerta/plugins/slack.py
# Slack plugin configuration
SLACK_API_KEY = 'xoxb-your-slack-bot-token'
SLACK_CHANNEL = '#alerts'
SLACK_USERNAME = 'Alerta'
SLACK_ICON_EMOJI = ':warning:'
SLACK_ATTACHMENTS = True
SLACK_COLOR = True
SLACK_FIELD_MAP = {
'resource': 'Resource',
'event': 'Event',
'environment': 'Environment',
'severity': 'Severity',
'status': 'Status',
'group': 'Group',
'value': 'Value',
'text': 'Description'
}
SLACK_DISABLE_SSL_VERIFICATION = False
SLACK_CACERT = '/etc/ssl/certs/ca-certificates.crt'
# /etc/alerta/plugins/pagerduty.py
# PagerDuty plugin configuration
PAGERDUTY_SERVICE_KEY = 'your-pagerduty-service-key'
PAGERDUTY_API_URL = 'https://events.pagerduty.com/generic/2010-04-15/create_event.json'
PAGERDUTY_PROXY = None
PAGERDUTY_SEVERITY_MAP = {
'security': 'critical',
'critical': 'critical',
'major': 'error',
'minor': 'warning',
'warning': 'warning',
'indeterminate': 'info',
'informational': 'info',
'normal': 'info',
'ok': 'info',
'cleared': 'info'
}
# /etc/alerta/plugins/email.py
# Email plugin configuration
SMTP_HOST = 'smtp.example.com'
SMTP_PORT = 587
SMTP_STARTTLS = True
SMTP_USERNAME = 'alerta@example.com'
SMTP_PASSWORD = 'EmailPassword123!'
SMTP_FROM = 'alerta@example.com'
EMAIL_RECIPIENTS = {
'Production': ['ops@example.com', 'admin@example.com'],
'Development': ['dev-team@example.com'],
'Database': ['dba@example.com'],
'Network': ['network-team@example.com']
}
EMAIL_SUBJECT_PREFIX = '[Alerta]'
EMAIL_BODY_TEMPLATE = '''
Alert: {event}
Resource: {resource}
Environment: {environment}
Severity: {severity}
Status: {status}
Group: {group}
Value: {value}
Text: {text}
Tags: {tags}
Attributes: {attributes}
Created: {create_time}
Last Received: {receive_time}
'''
# /etc/alerta/blackouts.py
# Blackout periods
BLACKOUT_PERIODS = [
{
'environment': 'Development',
'service': ['test-service'],
'resource': None,
'event': None,
'group': None,
'tags': None,
'origin': None,
'type': None,
'duration': 3600 # 1 hour
},
{
'environment': 'Production',
'service': None,
'resource': 'test-*',
'event': None,
'group': None,
'tags': ['maintenance'],
'origin': None,
'type': None,
'duration': 7200 # 2 hours
}
]
# /etc/alerta/plugins/webhook.py
import requests
import json
WEBHOOK_URLS = [
{
'name': 'Custom API',
'url': 'https://api.example.com/alerts',
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN'
},
'payload_template': {
'alert_id': '{{ id }}',
'resource': '{{ resource }}',
'event': '{{ event }}',
'severity': '{{ severity }}',
'status': '{{ status }}',
'environment': '{{ environment }}',
'group': '{{ group }}',
'value': '{{ value }}',
'text': '{{ text }}',
'tags': '{{ tags }}',
'attributes': '{{ attributes }}',
'create_time': '{{ create_time }}',
'receive_time': '{{ receive_time }}'
}
},
{
'name': 'Microsoft Teams',
'url': 'https://outlook.office.com/webhook/XXX/YYY/ZZZ',
'method': 'POST',
'headers': {
'Content-Type': 'application/json'
},
'payload_template': {
'@type': 'MessageCard',
'@context': 'http://schema.org/extensions',
'themeColor': '{{ severity_color }}',
'summary': '{{ event }}',
'sections': [{
'activityTitle': 'Alerta Alert',
'facts': [
{'name': 'Resource', 'value': '{{ resource }}'},
{'name': 'Event', 'value': '{{ event }}'},
{'name': 'Severity', 'value': '{{ severity }}'},
{'name': 'Environment', 'value': '{{ environment }}'},
{'name': 'Status', 'value': '{{ status }}'}
]
}]
}
}
]
def send_webhook(alert):
for webhook in WEBHOOK_URLS:
try:
payload = json.loads(json.dumps(webhook['payload_template']).replace('{{', '').replace('}}', ''))
for key, value in payload.items():
if isinstance(value, str):
payload[key] = str(alert.get(key.strip(), ''))
response = requests.post(
webhook['url'],
headers=webhook['headers'],
json=payload,
timeout=10
)
response.raise_for_status()
except Exception as e:
print(f"Failed to send webhook {webhook['name']}: {e}")
# Validate configuration syntax
alertad validate
# Test database connection
alertad --config /etc/alertad.conf db upgrade
# Check API health
curl http://localhost:8080/api/healthcheck
# Verify configuration
alertad --config /etc/alertad.conf info
# Restart Alerta server
sudo systemctl restart alertad
# Check service status
sudo systemctl status alertad
# View logs
sudo journalctl -u alertad -f
sudo tail -f /var/log/alerta/alertad.log
# Restart with gunicorn (if using)
sudo systemctl restart gunicorn-alerta
# Initialize database
alertad --config /etc/alertad.conf db init
# Upgrade database schema
alertad --config /etc/alertad.conf db upgrade
# Create admin user
alertad --config /etc/alertad.conf user create --name Admin --email admin@example.com --password AdminPassword123! --role admin
# List users
alertad --config /etc/alertad.conf user list
# Check API health
curl http://localhost:8080/api/healthcheck
# Get API info
curl http://localhost:8080/api
# List alerts
curl -H "Authorization: Key YOUR_API_KEY" http://localhost:8080/api/alerts
# Get alert by ID
curl -H "Authorization: Key YOUR_API_KEY" http://localhost:8080/api/alert/ALERT_ID
# Check metrics
curl http://localhost:8080/metrics
# Access web interface
curl http://localhost:8080
# Check config endpoint
curl http://localhost:8080/config.js
# Test Slack plugin
alerta send --resource test --event test_event --severity warning --plugin slack
# Test email plugin
alerta send --resource test --event test_event --severity warning --plugin email
# Check plugin status
alerta plugins list
# Login and get token
curl -X POST http://localhost:8080/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin@example.com","password":"AdminPassword123!"}'
# Use token to access API
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8080/api/alerts
Squeezing every bit of performance from your Alerta installation? Our experts help with:
Optimize your setup: office@linux-server-admin.com | Contact Us