Skip to main content
GET
/
varz
curl -X GET "http://localhost:5001/varz?sort=in_msgs&conn_limit=50"
{
  "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

sort
string
default:"in_msgs"
Sort field
  • in_msgs - Sort by received message count
  • out_msgs - Sort by sent message count
  • in_bytes - Sort by received bytes
  • out_bytes - Sort by sent bytes
conn_limit
integer
default:20
Connection information limit count
node_id
integer
Specify node ID (cluster environment)
curl -X GET "http://localhost:5001/varz?sort=in_msgs&conn_limit=50"
{
  "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

server_id
string
required
Server identifier
version
string
required
WuKongIM version number
git_commit
string
required
Git commit hash
go_version
string
required
Go language version

Runtime Information

start
string
required
Server start time (ISO 8601 format)
now
string
required
Current time (ISO 8601 format)
uptime
string
required
Runtime duration

Connection Statistics

connections
integer
required
Current connection count
total_connections
integer
required
Total connections (historical cumulative)
slow_consumers
integer
required
Number of slow consumers
subscriptions
integer
required
Total subscriptions

Message Statistics

in_msgs
integer
required
Total received messages
out_msgs
integer
required
Total sent messages
in_bytes
integer
required
Total received bytes
out_bytes
integer
required
Total sent bytes

HTTP Request Statistics

http_req_stats
object
required
HTTP request statistics

System Resources

cpu
number
required
CPU usage (percentage)
mem
integer
required
Memory usage (bytes)

Configuration Information

config
object
required
System configuration information

Status Codes

Status CodeDescription
200Successfully retrieved system variables
500Internal server error

Monitoring Metrics Description

Performance Metrics

MetricDescriptionNormal RangeAlert Threshold
CPU UsageServer CPU utilization percentage< 70%> 80%
Memory UsageServer memory consumption< 80%> 90%
ConnectionsCurrent active connectionsBased on configNear maximum
Slow ConsumersNumber of slow processing connections< 5%> 10%

Throughput Metrics

MetricDescriptionMonitoring Focus
Message Receive RateMessages received per secondSudden increases or decreases
Message Send RateMessages sent per secondRatio to receive rate
Byte Transfer RateNetwork transfer speedBandwidth usage
HTTP Request StatsAPI call frequency and response timeHot APIs and performance bottlenecks

Best Practices

  1. Regular Monitoring: Recommended to get system variables every 30-60 seconds
  2. Alert Setup: Set reasonable alert thresholds for key metrics
  3. Trend Analysis: Record historical data to analyze system performance trends
  4. Capacity Planning: Perform capacity planning based on monitoring data
  5. Performance Optimization: Identify performance bottlenecks and optimize
  6. Cluster Monitoring: Monitor all node status in cluster environments