Netdata.cloud bot for Zulip
Netdata Zulip Bot - Development Instructions#
This repository implements a Zulip bot that receives incoming webhook notifications from Netdata Cloud and posts the resulting notifications to a Zulip topic.
Core Requirements#
Technology Stack#
- Language: Python with
uvpackage manager - Framework: Python
zulip_botsPyPI package for Zulip integration - Web Server: FastAPI for webhook endpoint
- Deployment: Standalone service
Netdata Integration#
- Webhook Format: Follow the Netdata Cloud webhook notification format from:
- URL:
https://raw.githubusercontent.com/netdata/netdata/refs/heads/master/integrations/cloud-notifications/metadata.yaml - Section:
id: notify-cloud-webhook
- URL:
- Notification Types: Handle both alert notifications and reachability notifications
Zulip Configuration#
- Configuration Source: The
.zuliprcfile should contain:- Zulip site URL
- Bot email and API key
- Target stream/channel for posting messages
- Topic Organization: Messages should be posted to topics based on severity:
critical,warning,clearfor alertsreachabilityfor host status changes
- Message Format: Rich markdown with:
- Alert details and timestamps
- Markdown-formatted alert URLs for easy access to Netdata Cloud
Security Requirements#
- TLS/HTTPS: The service must listen on HTTPS (not HTTP)
- Let's Encrypt: Use Let's Encrypt to automatically issue SSL certificates for the public hostname
- Mutual TLS: Netdata uses mutual TLS for authentication
- The server must validate Netdata's client certificate
- Support configuration of client CA certificate path
Service Architecture#
- Standalone Service: Run as an independent service
- Webhook Endpoint: Expose
/webhook/netdatafor receiving notifications - Health Check: Provide
/healthendpoint for monitoring - Structured Logging: Use JSON-structured logs for production monitoring
Implementation Notes#
Configuration Management#
- Support both
.zuliprcfile and environment variables - Provide sample configuration files with
--create-configflag - Server configuration via environment variables:
SERVER_DOMAIN: Public domain for Let's EncryptSERVER_PORT: HTTPS port (default: 8443)SERVER_ENABLE_MTLS: Enable mutual TLSSERVER_CLIENT_CA_PATH: Path to Netdata client CA
Message Processing#
- Receive Netdata webhook POST request
- Validate and parse JSON payload
- Determine notification type (alert vs reachability)
- Format message with appropriate emoji and markdown
- Send to configured Zulip stream/topic
Error Handling#
- Validate all incoming payloads
- Log errors without exposing internal details
- Return appropriate HTTP status codes
- Implement retry logic for Zulip API failures
Testing#
Run tests with:
uv run python -m pytest tests/ -v
Deployment#
The service should be deployable via:
- Systemd service (see
examples/netdata-zulip-bot.service) - Docker container (see
Dockerfileanddocker-compose.yml) - Automated setup script (
scripts/setup.sh)
Development Commands#
- Install dependencies:
uv sync - Create config samples:
uv run netdata-zulip-bot --create-config - Run tests:
uv run python -m pytest tests/ - Start service:
uv run netdata-zulip-bot
Important Reminders#
- Always validate Netdata webhook payloads before processing
- Ensure SSL certificates are properly configured before production deployment
- Test mutual TLS authentication with actual Netdata Cloud webhooks
- Monitor service logs for webhook processing errors
- Keep Zulip API credentials secure and never commit them to the repository