Add minecraft server metrics.

This commit is contained in:
olomana 2023-02-12 02:27:30 +00:00
parent af34ee9961
commit 8fe0549a0f
3 changed files with 25 additions and 11 deletions

View File

@ -11,11 +11,8 @@ scrape_configs:
scrape_interval: 5s scrape_interval: 5s
static_configs: static_configs:
- targets: ['node_exporter:9100'] - targets: ['node_exporter:9100']
- job_name: 'minecraft_2023' - job_name: 'minecraft_2023_metrics'
scrape_interval: 5s scrape_interval: 5s
static_configs: static_configs:
- targets: ['minecraft_2023:9225'] - targets: ['minecraft_2023_metrics:2565']
- job_name: 'minecraft_creative'
scrape_interval: 5s
static_configs:
- targets: ['minecraft_creative:9225']

View File

@ -5,10 +5,9 @@ PWS hosts Minecraft servers. Based off `https://github.com/itzg/docker-minecraft
All server configuration done with env vars. All server configuration done with env vars.
Data stored on disk rather than docker volume so things like the config can be edited via just ssh. Data stored on disk rather than docker volume so things like the config can be edited via just ssh.
Minecraft emits metrics for prometheus to collect via `https://github.com/sladkoff/minecraft-prometheus-exporter`. Clone the repo & build the project into a jar and copy it into the `/plugins` directory for minecraft. Minecraft emits metrics for Prometheus to collect for Grafana. We are exporting metrics via the docker container described in `https://github.com/Joshi425/minecraft-exporter`. Change the default port via env variable to make sure there aren't port conflicts.
Take special care to overwrite the plugin's default "hostname" to `0.0.0.0` to allow all traffic in the config file. Otherwise the minecraft target will show up as DOWN in Prometheus. This allows the plugin to listen to traffic from outside the container (namely the prometheus instance).
Monitoring commands to get logs from the container are documented in the github repo. Monitoring commands to get logs from the minecraft container are documented in the github repo.
example: `docker exec minecraft_2023 mc_log` example: `docker exec minecraft_2023 mc_log`
@ -23,8 +22,6 @@ example: `docker exec minecraft_2023 mc_log`
##### Plugins ##### Plugins
Metrics: `https://github.com/sladkoff/minecraft-prometheus-exporter` as described above. Build jar and copy to jars folder. Ensure hostname is set to 0.0.0.0 to allow for remote pings.
SinglePlayerSleep: `https://www.spigotmc.org/resources/singleplayersleep.68139/` SinglePlayerSleep: `https://www.spigotmc.org/resources/singleplayersleep.68139/`
Dynmap: `https://www.spigotmc.org/resources/dynmap%C2%AE.274/` Dynmap: `https://www.spigotmc.org/resources/dynmap%C2%AE.274/`

View File

@ -69,3 +69,23 @@ services:
- "traefik.http.routers.minemap.rule=Host(`minemap.whitney.rip`)" - "traefik.http.routers.minemap.rule=Host(`minemap.whitney.rip`)"
- "traefik.http.routers.minemap.entrypoints=web" - "traefik.http.routers.minemap.entrypoints=web"
minecraft_2023_metrics:
image: joshi425/minecraft_exporter:latest
container_name: minecraft_2023_metrics
restart: always
networks:
- minecraft_network
ports:
- 2565:2565
volumes:
- /data/minecraft_2023/world:/world
environment:
- RCON_HOST=127.0.0.1
- RCON_PORT=25565
- HTTP_PORT=2565
- FORGE_SERVER="False"
- PAPER_SERVER="True"
- DYNMAP_ENABLED="True"