Monitoring
Setting up comprehensive monitoring for WuKongIM ensures optimal performance and early detection of issues.Prerequisites
Install Prometheus for metrics collection and monitoring.Install Prometheus
Configure Prometheus
Add WuKongIM monitoring targets under thescrape_configs section in your Prometheus configuration.
Single Node Configuration
For single node deployment, create/etc/prometheus/prometheus.yml:
Multi-Node Configuration
For multi-node cluster deployment:job_name: Unique job name for each WuKongIM nodetargets: WuKongIM internal IP + port 5300labels.id: WuKongIM node IDlabels.instance: Human-readable instance name
xx.xx.xx.xx with the actual internal IP address of your WuKongIM nodes.
Configure WuKongIM
Add Prometheus configuration to each node’swk.yaml file:
xx.xx.xx.xx with the internal IP address of your Prometheus server.
Complete WuKongIM Configuration Example
Start Services
Start Prometheus
Create a systemd service file for Prometheus:Restart WuKongIM
After updating the configuration, restart WuKongIM on all nodes:Verification
Check Prometheus Targets
- Access Prometheus web interface:
http://prometheus-server-ip:9090 - Go to Status → Targets
- Verify all WuKongIM targets are UP
Check Metrics
Query WuKongIM metrics in Prometheus:Key Metrics to Monitor
System Metrics
| Metric | Description |
|---|---|
wukongim_connections_total | Total number of active connections |
wukongim_messages_total | Total number of messages processed |
wukongim_memory_usage_bytes | Memory usage in bytes |
wukongim_cpu_usage_percent | CPU usage percentage |
wukongim_disk_usage_bytes | Disk usage in bytes |
Cluster Metrics (Multi-node)
| Metric | Description |
|---|---|
wukongim_cluster_nodes_total | Total number of cluster nodes |
wukongim_cluster_leader_changes_total | Number of leader changes |
wukongim_cluster_proposals_failed_total | Failed proposals count |
wukongim_cluster_proposals_committed_total | Committed proposals count |
Performance Metrics
| Metric | Description |
|---|---|
wukongim_message_latency_seconds | Message processing latency |
wukongim_api_request_duration_seconds | API request duration |
wukongim_websocket_connections | WebSocket connections count |
wukongim_tcp_connections | TCP connections count |
Alerting Rules
Create alerting rules in/etc/prometheus/alert_rules.yml:
Grafana Dashboard
Install Grafana
Configure Data Source
- Access Grafana:
http://grafana-server-ip:3000(admin/admin) - Add Prometheus data source:
http://prometheus-server-ip:9090 - Import WuKongIM dashboard or create custom dashboards

