mc-monitor is a monitoring tool bundled with the itzg/minecraft-server image that provides health checks, status monitoring, and metrics reporting capabilities for Minecraft servers.
Version: 0.16.1
Repository: itzg/mc-monitor
Repository: itzg/mc-monitor
Overview
mc-monitor can perform server status checks, export metrics for monitoring systems like Prometheus, and provide data for telegraf. It’s primarily used for:
- Docker container health checks
- Prometheus metrics export
- Telegraf data collection
- Server status monitoring
Health Checks
The image usesmc-monitor for built-in Docker health checks. You can see the health status in docker ps:
Health Check Wrapper
Themc-health wrapper script calls mc-monitor status with the correct arguments:
- Server host (default: localhost)
- Server port (default: 25565)
- Connection status
- Server responsiveness
Customizing Health Checks
In a Docker Compose file:Disabling Health Checks
Some orchestration systems don’t allow disabling health checks. In those cases:Health checks are automatically disabled for Minecraft versions before Beta 1.8, as those versions don’t support server pinging.
Status Command
Basic Usage
Check server status:With Docker
From outside the container:Options
--host- Server hostname or IP (default: localhost)--port- Server port (default: 25565)--timeout- Connection timeout duration--retry- Number of retry attempts--retry-interval- Delay between retries
Examples
Prometheus Metrics Export
mc-monitor can export Prometheus-compatible metrics:
Metrics Provided
- Player count (current/max)
- Server status (up/down)
- Server version
- Response time
- TPS (ticks per second, when supported)
Docker Compose Example
Prometheus Configuration
Add to yourprometheus.yml:
Telegraf Integration
mc-monitor can output data in telegraf-compatible format:
Telegraf Configuration
Command Reference
status
Check if a Minecraft server is running and responsive.--host <HOST>- Server hostname (default: localhost)--port <PORT>- Server port (default: 25565)--timeout <DURATION>- Connection timeout--retry <COUNT>- Number of retries--retry-interval <DURATION>- Delay between retries
0- Server is healthy1- Server is not responding or unhealthy
export-prometheus
Start a Prometheus metrics exporter.--port <PORT>- Port to expose metrics on (default: 9100)--host <HOST>- Minecraft server host to monitor--mc-port <PORT>- Minecraft server port--interval <DURATION>- Scrape interval
export-telegraf
Export metrics in telegraf format.--host <HOST>- Minecraft server host--port <PORT>- Minecraft server port
Environment Variables
Themc-health wrapper script respects these environment variables:
SERVER_HOST- Override server host (default: localhost)SERVER_PORT- Override server port (default: 25565)DISABLE_HEALTHCHECK- Disable health checks entirelyENABLE_AUTOPAUSE- Health check considers paused stateMC_HEALTH_EXTRA_ARGS- Additional arguments for mc-monitor
Example
Advanced Usage
Health Check Configuration File
Create/data/.mc-health.env to customize health check behavior:
Monitoring Multiple Servers
Monitor multiple servers with different configurations:Integration with Monitoring Systems
Usemc-monitor in monitoring scripts:
Compatibility
mc-monitor supports:
- Java Edition servers (all versions with server list ping support)
- Bedrock Edition servers
- Various server types (Vanilla, Paper, Spigot, Forge, Fabric, etc.)
- Multiple protocol versions
Troubleshooting
Health Check Failing
If health checks are failing:- Verify server is fully started (increase
start_period) - Check server is bound to correct port
- Ensure server is not paused (if using Auto-Pause)
- Check network connectivity
Connection Timeout
Increase timeout for slow-starting servers:False Negatives with Auto-Pause
When Auto-Pause is enabled, the health check detects suspended Java processes:Related Commands
See also:- rcon-cli - Send commands to server
- mc-image-helper - Server setup and configuration