curl -X GET "http://localhost:5001/varz?sort=in_msgs&conn_limit=50"
const response = await fetch('http://localhost:5001/varz?sort=in_msgs&conn_limit=50');
const data = await response.json();
console.log(data);
import requests
params = {
'sort': 'in_msgs',
'conn_limit': 50
}
response = requests.get('http://localhost:5001/varz', params=params)
data = response.json()
print(data)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/varz?sort=in_msgs&conn_limit=50")
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"server_id": "wukongim-node-1",
"version": "2.0.0",
"git_commit": "abc123def",
"go_version": "go1.21.0",
"start": "2024-01-15T08:00:00Z",
"now": "2024-01-15T10:30:00Z",
"uptime": "2h30m0s",
"connections": 1250,
"total_connections": 15000,
"in_msgs": 125000,
"out_msgs": 130000,
"in_bytes": 12500000,
"out_bytes": 13000000,
"slow_consumers": 5,
"subscriptions": 8500,
"http_req_stats": {
"uri_stats": [
{
"uri": "/message/send",
"count": 5000,
"avg_time": "15ms"
},
{
"uri": "/channel/create",
"count": 200,
"avg_time": "25ms"
}
]
},
"cpu": 15.5,
"mem": 536870912,
"config": {
"max_connections": 10000,
"max_subscriptions_per_conn": 100,
"max_payload": 1048576
}
}
Monitoring
Get System Variables
Get system variables and performance metrics
GET
/
varz
curl -X GET "http://localhost:5001/varz?sort=in_msgs&conn_limit=50"
const response = await fetch('http://localhost:5001/varz?sort=in_msgs&conn_limit=50');
const data = await response.json();
console.log(data);
import requests
params = {
'sort': 'in_msgs',
'conn_limit': 50
}
response = requests.get('http://localhost:5001/varz', params=params)
data = response.json()
print(data)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/varz?sort=in_msgs&conn_limit=50")
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"server_id": "wukongim-node-1",
"version": "2.0.0",
"git_commit": "abc123def",
"go_version": "go1.21.0",
"start": "2024-01-15T08:00:00Z",
"now": "2024-01-15T10:30:00Z",
"uptime": "2h30m0s",
"connections": 1250,
"total_connections": 15000,
"in_msgs": 125000,
"out_msgs": 130000,
"in_bytes": 12500000,
"out_bytes": 13000000,
"slow_consumers": 5,
"subscriptions": 8500,
"http_req_stats": {
"uri_stats": [
{
"uri": "/message/send",
"count": 5000,
"avg_time": "15ms"
},
{
"uri": "/channel/create",
"count": 200,
"avg_time": "25ms"
}
]
},
"cpu": 15.5,
"mem": 536870912,
"config": {
"max_connections": 10000,
"max_subscriptions_per_conn": 100,
"max_payload": 1048576
}
}
Overview
Get WuKongIM system runtime variables and performance metrics for system monitoring and performance analysis.Query Parameters
string
default:"in_msgs"
Sort field
in_msgs- Sort by received message countout_msgs- Sort by sent message countin_bytes- Sort by received bytesout_bytes- Sort by sent bytes
integer
default:20
Connection information limit count
integer
Specify node ID (cluster environment)
curl -X GET "http://localhost:5001/varz?sort=in_msgs&conn_limit=50"
const response = await fetch('http://localhost:5001/varz?sort=in_msgs&conn_limit=50');
const data = await response.json();
console.log(data);
import requests
params = {
'sort': 'in_msgs',
'conn_limit': 50
}
response = requests.get('http://localhost:5001/varz', params=params)
data = response.json()
print(data)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/varz?sort=in_msgs&conn_limit=50")
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"server_id": "wukongim-node-1",
"version": "2.0.0",
"git_commit": "abc123def",
"go_version": "go1.21.0",
"start": "2024-01-15T08:00:00Z",
"now": "2024-01-15T10:30:00Z",
"uptime": "2h30m0s",
"connections": 1250,
"total_connections": 15000,
"in_msgs": 125000,
"out_msgs": 130000,
"in_bytes": 12500000,
"out_bytes": 13000000,
"slow_consumers": 5,
"subscriptions": 8500,
"http_req_stats": {
"uri_stats": [
{
"uri": "/message/send",
"count": 5000,
"avg_time": "15ms"
},
{
"uri": "/channel/create",
"count": 200,
"avg_time": "25ms"
}
]
},
"cpu": 15.5,
"mem": 536870912,
"config": {
"max_connections": 10000,
"max_subscriptions_per_conn": 100,
"max_payload": 1048576
}
}
Response Fields
Server Information
string
required
Server identifier
string
required
WuKongIM version number
string
required
Git commit hash
string
required
Go language version
Runtime Information
string
required
Server start time (ISO 8601 format)
string
required
Current time (ISO 8601 format)
string
required
Runtime duration
Connection Statistics
integer
required
Current connection count
integer
required
Total connections (historical cumulative)
integer
required
Number of slow consumers
integer
required
Total subscriptions
Message Statistics
integer
required
Total received messages
integer
required
Total sent messages
integer
required
Total received bytes
integer
required
Total sent bytes
HTTP Request Statistics
object
required
System Resources
number
required
CPU usage (percentage)
integer
required
Memory usage (bytes)
Configuration Information
object
required
Status Codes
| Status Code | Description |
|---|---|
| 200 | Successfully retrieved system variables |
| 500 | Internal server error |
Monitoring Metrics Description
Performance Metrics
| Metric | Description | Normal Range | Alert Threshold |
|---|---|---|---|
| CPU Usage | Server CPU utilization percentage | < 70% | > 80% |
| Memory Usage | Server memory consumption | < 80% | > 90% |
| Connections | Current active connections | Based on config | Near maximum |
| Slow Consumers | Number of slow processing connections | < 5% | > 10% |
Throughput Metrics
| Metric | Description | Monitoring Focus |
|---|---|---|
| Message Receive Rate | Messages received per second | Sudden increases or decreases |
| Message Send Rate | Messages sent per second | Ratio to receive rate |
| Byte Transfer Rate | Network transfer speed | Bandwidth usage |
| HTTP Request Stats | API call frequency and response time | Hot APIs and performance bottlenecks |
Best Practices
- Regular Monitoring: Recommended to get system variables every 30-60 seconds
- Alert Setup: Set reasonable alert thresholds for key metrics
- Trend Analysis: Record historical data to analyze system performance trends
- Capacity Planning: Perform capacity planning based on monitoring data
- Performance Optimization: Identify performance bottlenecks and optimize
- Cluster Monitoring: Monitor all node status in cluster environments

