An efficient AlertManager webhook processing service with multi-platform notifications and multilingual template support.
- ๐ Key Features
- ๐ Supported Platforms
- โก Quick Start
- ๐ Chat IDs Level Mapping
- ๐ Documentation
- ๐ ๏ธ Development
- ๐ AlertManager Webhook Sample
- ๐ Project Structure
- ๐ Languages
- ๐ AlertManager Integration: Direct webhook processing from AlertManager
- ๐ฑ Multi-Platform Notifications: Support for Telegram, Slack, and Discord
- ๐ฏ Multi-Level Notifications: Support for different alert level group distribution
- ๐ Multilingual Templates: English, Traditional Chinese, Simplified Chinese, Japanese, Korean
- ๐ Hot Reload: Dynamic configuration and template reloading without service restart
- ๐ Secure Authentication: HTTP Basic Auth protection
- ๐ Dual Template Modes: Full/Minimal display formats
- ๐จ Separate Notifications: Firing and resolved alerts sent separately
- ๐จ Custom Templates: Support for custom message templates and formats
This service supports alert notifications for the following communication platforms:
- โ Support for multiple chat groups
- โ Support for different level notification distribution
- โ Support for bot information queries
- โ Support for custom message formats
- โ Support for Webhook notifications
- โ Support for channel message sending
- โ Support for custom message formats
- โ Support for attachments and formatted messages
- โ Support for server channel notifications
- โ Support for Webhook messages
- โ Support for rich message formats
- โ Support for embedded messages
go mod download# Copy configuration file
cp examples/config.expamle.yaml configs/config.development.yaml
# Edit configuration (set Telegram token and chat IDs)
vim configs/config.development.yaml# Development environment
make dev
# or
go run cmd/main.go -e development
# Production environment
make run
# or
go run cmd/main.go -e productionOpen browser: http://localhost:9999/swagger/index.html
| Chat IDs | Level | Group Purpose | Description |
|---|---|---|---|
| chat_ids0 | L0 | Information Group | General information and status updates |
| chat_ids1 | L1 | General Message Group | Standard alerts and daily monitoring |
| chat_ids2 | L2 | Critical Notification Group | Important alerts and critical system notifications |
| chat_ids3 | L3 | Emergency Alert Group | Emergency events and severe failure notifications |
| chat_ids4 | L4 | Testing Group | Testing and development environment notifications |
| chat_ids5 | L5 | Backup Group | Backup and disaster recovery notification group |
Complete setup and usage guides are available in multiple languages in the documentation directory:
- English Documentation - Complete English documentation
- ็น้ซไธญๆๆๆช - Complete Traditional Chinese documentation
- Configuration Guide - Detailed configuration instructions
- Service Enable Configuration - Service enablement settings
- Kubernetes Environment Variables - K8s deployment configuration
- Swagger Troubleshooting - API documentation issue resolution
- Template Guide - Custom template instructions
- Template Mode Configuration - Full/Minimal mode settings
- Template Usage Examples - Template practical application examples
- Telegram Setup - Telegram bot configuration
- Slack Setup - Slack application configuration
- Discord Setup - Discord bot configuration
- Telegram Usage Examples - Telegram API usage examples
- Slack Usage Examples - Slack API usage examples
- Discord Usage Examples - Discord API usage examples
make dev # Start development environment
make build # Build project
make test # Run tests
make swagger-generate # Regenerate Swagger documentation
make fmt # Format code
make lint # Code quality check| Method | Path | Description | Authentication |
|---|---|---|---|
POST |
/api/v1/telegram/chatid_{level} |
Send Telegram message | โ Basic Auth |
GET |
/api/v1/telegram/info |
Get bot information | โ Basic Auth |
| Method | Path | Description | Authentication |
|---|---|---|---|
POST |
/api/v1/slack/chatid_{level} |
Send Slack message | โ Basic Auth |
GET |
/api/v1/slack/info |
Get Slack info | โ Basic Auth |
| Method | Path | Description | Authentication |
|---|---|---|---|
POST |
/api/v1/discord/chatid_{level} |
Send Discord message | โ Basic Auth |
GET |
/api/v1/discord/info |
Get Discord info | โ Basic Auth |
| Method | Path | Description | Authentication |
|---|---|---|---|
GET |
/api/v1/healthz |
Health check | โ |
GET |
/swagger/* |
API documentation | โ Basic Auth |
# alertmanager.yml - Telegram Setup
route:
receiver: "telegram-notifications"
receivers:
- name: "telegram-notifications"
webhook_configs:
- url: "http://localhost:9999/api/v1/telegram/chatid_L0"
http_config:
basic_auth:
username: "admin"
password: "admin"# alertmanager.yml - Slack Setup
route:
receiver: "slack-notifications"
receivers:
- name: "slack-notifications"
webhook_configs:
- url: "http://localhost:9999/api/v1/slack/chatid_L1"
http_config:
basic_auth:
username: "admin"
password: "admin"# alertmanager.yml - Discord Setup
route:
receiver: "discord-notifications"
receivers:
- name: "discord-notifications"
webhook_configs:
- url: "http://localhost:9999/api/v1/discord/chatid_L1"
http_config:
basic_auth:
username: "admin"
password: "admin"# alertmanager.yml - Multi-Platform Setup
route:
receiver: "multi-platform-notifications"
receivers:
- name: "multi-platform-notifications"
webhook_configs:
# Telegram notification
- url: "http://localhost:9999/api/v1/telegram/chatid_L2"
http_config:
basic_auth:
username: "admin"
password: "admin"
# Slack notification
- url: "http://localhost:9999/api/v1/slack/chatid_L2"
http_config:
basic_auth:
username: "admin"
password: "admin"
# Discord notification
- url: "http://localhost:9999/api/v1/discord/chatid_L2"
http_config:
basic_auth:
username: "admin"
password: "admin"The raw_alertmanager.json file in the project root provides a complete Prometheus AlertManager webhook payload sample, including:
{
"receiver": "test-telegram-webhook", // Receiver name
"status": "firing", // Alert status: firing/resolved
"alerts": [
// Alert array
{
"status": "firing", // Individual alert status
"labels": {
// Alert labels
"alertname": "TEST_Pod_CPU_Usage High", // Alert name
"env": "uat", // Environment label
"namespace": "hcgateconsole", // Kubernetes namespace
"pod": "hcgateconsole-deploy-xxx", // Pod name
"severity": "test-alert" // Severity level
},
"annotations": {
// Alert annotations
"summary": "Pod CPU usage exceeds 80%" // Alert summary
},
"startsAt": "2022-11-18T08:17:31.745Z", // Alert start time
"endsAt": "0001-01-01T00:00:00Z", // Alert end time (empty when firing)
"generatorURL": "http://prometheus...", // Prometheus query link
"fingerprint": "2da0690c63cf9cd3" // Alert fingerprint ID
}
],
"groupLabels": {
// Group labels
"alertname": "TEST_Pod_CPU_Usage High",
"env": "uat",
"severity": "test-alert"
},
"commonLabels": {
// Common labels
"alertname": "TEST_Pod_CPU_Usage High",
"env": "uat",
"severity": "test-alert"
},
"commonAnnotations": {}, // Common annotations
"externalURL": "http://prometheus-alertmanager:9093", // AlertManager external URL
"version": "4", // AlertManager version
"groupKey": "...", // Group identification key
"truncatedAlerts": 0 // Number of truncated alerts
}- Development Testing: Test webhook endpoint functionality
- Template Development: Reference data for developing custom alert templates
- Debug Analysis: Analyze webhook structure sent by AlertManager
- Documentation Reference: Understand complete AlertManager webhook payload format
The sample file contains alerts in two states:
-
๐ฅ Firing Alerts (3 alerts)
- Active alerts for Pod CPU usage exceeding 80%
- CPU high usage alerts for different Pods
-
โ Resolved Alerts (1 alert)
- Resolved CPU usage alerts
- Includes complete start and end times
# Test webhook endpoint using curl
curl -X POST http://localhost:9999/api/v1/telegram/chatid_L4 \
-H "Content-Type: application/json" \
-H "Authorization: Basic $(echo -n admin:admin | base64)" \
-d @raw_alertmanager.json
# Test other platforms
curl -X POST http://localhost:9999/api/v1/slack/chatid_L4 \
-H "Content-Type: application/json" \
-H "Authorization: Basic $(echo -n admin:admin | base64)" \
-d @raw_alertmanager.json
curl -X POST http://localhost:9999/api/v1/discord/chatid_L4 \
-H "Content-Type: application/json" \
-H "Authorization: Basic $(echo -n admin:admin | base64)" \
-d @raw_alertmanager.jsonalert-webhooks/
โโโ cmd/ # Main program entry
โ โโโ main.go # Application entry point
โโโ config/ # Configuration management modules
โ โโโ app.go # Application configuration
โ โโโ config.go # Main configuration file
โ โโโ discord.go # Discord configuration
โ โโโ logger.go # Logger configuration
โ โโโ manager.go # Configuration manager
โ โโโ metric.go # Monitoring metrics configuration
โ โโโ slack.go # Slack configuration
โ โโโ telgram.go # Telegram configuration
โ โโโ webhooks.go # Webhook configuration
โโโ configs/ # Configuration file directory
โ โโโ alert_config.minimal.yaml # Minimal alert configuration
โ โโโ alert_config.yaml # Complete alert configuration
โ โโโ config.development.yaml # Development environment configuration
โโโ docs/ # Swagger API documentation
โ โโโ docs.go # Documentation generator
โ โโโ swagger.json # JSON format API documentation
โ โโโ swagger.yaml # YAML format API documentation
โโโ documentation/ # ๐ Project documentation
โ โโโ en/ # English documentation
โ โ โโโ config_guide.md # Configuration guide
โ โ โโโ discord_setup.md # Discord setup
โ โ โโโ discord_usage.md # Discord usage examples
โ โ โโโ slack_setup.md # Slack setup
โ โ โโโ slack_usage.md # Slack usage examples
โ โ โโโ telegram_setup.md # Telegram setup
โ โ โโโ telegram_usage.md # Telegram usage examples
โ โ โโโ template_guide.md # Template guide
โ โโโ zh/ # Chinese documentation
โ โโโ config_guide.md # Configuration guide
โ โโโ discord_setup.md # Discord setup
โ โโโ discord_usage.md # Discord usage examples
โ โโโ slack_setup.md # Slack setup
โ โโโ slack_usage.md # Slack usage examples
โ โโโ telegram_setup.md # Telegram setup
โ โโโ telegram_usage.md # Telegram usage examples
โ โโโ template_guide.md # Template guide
โโโ examples/ # Usage examples
โ โโโ config_usage.go # Configuration usage example
โ โโโ config.expamle.yaml # Configuration example file
โโโ pkg/ # Core functionality packages
โ โโโ logcore/ # Logging core
โ โ โโโ core.go # Logging core implementation
โ โโโ logger/ # Logging system
โ โ โโโ logger.go # Logger implementation
โ โ โโโ middleware.go # Logging middleware
โ โ โโโ utils.go # Logging utility functions
โ โโโ logutil/ # Logging utilities
โ โ โโโ context.go # Context logging utilities
โ โโโ middleware/ # HTTP middleware
โ โ โโโ basic_auth.go # Basic authentication middleware
โ โ โโโ cors.go # CORS middleware
โ โ โโโ logger.go # Logging middleware
โ โ โโโ recovery.go # Recovery middleware
โ โโโ notification/ # Notification system
โ โ โโโ manager.go # Notification manager
โ โ โโโ providers/ # Notification providers
โ โ โ โโโ discord.go # Discord notification implementation
โ โ โ โโโ slack.go # Slack notification implementation
โ โ โ โโโ telegram.go # Telegram notification implementation
โ โ โโโ types/ # Notification type definitions
โ โ โโโ types.go # Notification type structures
โ โโโ service/ # Business service layer
โ โ โโโ discord.go # Discord service
โ โ โโโ service.go # Common service interface
โ โ โโโ slack.go # Slack service
โ โ โโโ telegram.go # Telegram service
โ โโโ template/ # Template engine
โ โ โโโ engine.go # Template engine implementation
โ โโโ watcher/ # File monitoring
โ โโโ config_watcher.go # Configuration file monitor
โโโ routes/ # API routing system
โ โโโ api/ # API routes
โ โ โโโ v1/ # API v1 version
โ โ โโโ discord/ # Discord API routes
โ โ โ โโโ handler.go # Discord handler
โ โ โ โโโ routes.go # Discord route definitions
โ โ โโโ slack/ # Slack API routes
โ โ โ โโโ handler.go # Slack handler
โ โ โ โโโ routes.go # Slack route definitions
โ โ โโโ telegram/ # Telegram API routes
โ โ โ โโโ handler.go # Telegram handler
โ โ โ โโโ routes.go # Telegram route definitions
โ โ โโโ healthCheck.go # Health check endpoint
โ โ โโโ register.go # Route registrar
โ โโโ mainRoute.go # Main route configuration
โโโ scripts/ # Utility scripts
โ โโโ fix_swagger_docs.go # Swagger documentation fix script
โ โโโ regenerate_swagger.sh # Swagger regeneration script
โโโ templates/ # Message templates
โ โโโ alerts/ # Alert templates
โ โโโ alert_template_eng.tmpl # English alert template
โ โโโ alert_template_ja.tmpl # Japanese alert template
โ โโโ alert_template_ko.tmpl # Korean alert template
โ โโโ alert_template_tw.tmpl # Traditional Chinese alert template
โ โโโ alert_template_zh.tmpl # Simplified Chinese alert template
โโโ kubernetes/ # Kubernetes deployment configuration
โ โโโ deployment-example.yaml # Deployment example configuration
โโโ docker-compose.yml # Docker Compose configuration
โโโ docker-compose.dev.yml # Development environment Docker Compose
โโโ Dockerfile # Docker image build file
โโโ Makefile # Build and management scripts
โโโ go.mod # Go module dependencies
โโโ go.sum # Go module checksums
โโโ raw_alertmanager.json # AlertManager webhook payload sample
โโโ README.md # English project documentation
โโโ README-zh.md # Chinese project documentation
- English (Current)
- ็น้ซไธญๆ
Issues and Pull Requests are welcome to improve this project!
This project is licensed under the MIT License.