Eranio
Color theme

Statistics

Base: /api/stats

The statistics endpoint returns a small, fast snapshot of the Java runtime of the Hytale server. It suits charts and alerts when the slim response is enough and you do not need the whole status with players and TPS. The values belong to the Java process of the server, not to the whole machine. For the CPU and total memory of the machine, use the status endpoint. As with every call to the HytaleAdminAPI, you need the X-Admin-Token header.

Handler: StatsHandler
GET /api/stats

Get statistics

Returns memory_used_mb (used heap), memory_free_mb (free part of the heap Java has currently reserved), memory_max_mb (upper limit of the Java runtime), processors (processors available to Java) and uptime_ms (milliseconds since the mod started).

Response Example

{
  "memory_used_mb": 512,
  "memory_max_mb": 4096,
  "memory_free_mb": 1500,
  "processors": 8,
  "uptime_ms": 4200000
}

cURL

curl -X GET 'http://localhost:5550/api/stats' \
  -H 'X-Admin-Token: YOUR_TOKEN'
memory_free_mb is not the distance to the upper limit but the free part of the heap that Java has reserved at the moment. Calculate the free headroom as memory_max_mb minus memory_used_mb. The values fluctuate with the garbage collection of Java, a short up and down is normal. Only a permanently high value close to memory_max_mb points to too little memory. The endpoint has no parameters. It answers methods other than GET with 405 and a missing or wrong token with 403. The values work well as a time series: if you poll the endpoint every 30 seconds, for example, and store memory_used_mb, you can see memory leaks and load peaks over time. The status endpoint additionally returns heap_percent, and uptime_ms means the same in both responses, namely the time since the mod started.

Internal Behavior

Reads the counters of the Java runtime directly, without touching worlds or files. The response is correspondingly light and suits frequent polling, for example for a chart.