Monitoring players position in the world with Minecraft Exporter

The Minecraft Exporter exposes a wide variety of metrics.

In this guide, you will:

  • Start up a Minecraft Exporter on localhost
  • Start up a Prometheus instance on localhost that’s configured to scrape metrics from the running Minecraft Exporter

Installing and running the Minecraft Exporter

The Minecraft Exporter is a single static binary that you can install via tarball. Once you’ve downloaded it from the downloads page extract it, and run it:

Current Release

Current Release

# NOTE: Replace the URL with one from the above mentioned "downloads" page.
# <VERSION>, <OS>, and <ARCH> are placeholders.
wget https://github.com/rebelcore/minecraft_exporter/releases/download/v<VERSION>/minecraft_exporter-<VERSION>.<OS>-<ARCH>.tar.gz
tar xvfz minecraft_exporter-*.*-amd64.tar.gz
cd minecraft_exporter-*.*-amd64
./minecraft_exporter

You should see output like this indicating that the Node Exporter is now running and exposing metrics on port 9940:

caller=minecraft_exporter.go:176 level=info msg="Starting minecraft_exporter" version="(version=1.0.0, branch=HEAD, revision=96d9b649c014cacda5dd60883d335cb17e67f900)"
caller=minecraft_exporter.go:177 level=info msg="Build context" build_context="(go=go1.23.1, platform=linux/amd64, user=root@0252ce7f94ff, date=20240910-22:11:32, tags=unknown)"
caller=minecraft_exporter.go:96 level=info msg="Enabled collectors"
caller=minecraft_exporter.go:103 level=info collector=media
caller=minecraft_exporter.go:103 level=info collector=system
caller=tls_config.go:348 level=info msg="Listening on" address=[::]:9940
caller=tls_config.go:351 level=info msg="TLS is disabled." http2=false address=[::]:9940

Minecraft Exporter metrics

Once the Minecraft Exporter is installed and running, you can verify that metrics are being exported by cURLing the /metrics endpoint:

curl http://localhost:9940/metrics

You should see output like this:

# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 3.8996e-05
go_gc_duration_seconds{quantile="0.25"} 4.5926e-05
go_gc_duration_seconds{quantile="0.5"} 5.846e-05
# etc.

Success! The Minecraft Exporter is now exposing metrics that Prometheus can scrape, including a wide variety of metrics further down in the output (prefixed with minecraft_). To view those metrics (along with help and type information):

curl http://localhost:9594/metrics | grep "minecraft_"

Configuring your Prometheus instances

Your locally running Prometheus instance needs to be properly configured in order to access Node Exporter metrics. The following prometheus.yml example configuration file will tell the Prometheus instance to scrape, and how frequently, from the Node Exporter via localhost:9594:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "minecraft"
    metrics_path: /metrics
    static_configs:
      - targets: ["127.0.0.1:9940"]

To install Prometheus, download the latest release for your platform and untar it:

Prometheus Latest Release

wget https://github.com/prometheus/prometheus/releases/download/v*/prometheus-*.*-amd64.tar.gz
tar xvf prometheus-*.*-amd64.tar.gz
cd prometheus-*.*

Once Prometheus is installed you can start it up, using the --config.file flag to point to the Prometheus configuration that you created above:

./prometheus --config.file=./prometheus.yml

Exploring Minecraft Exporter metrics through the Prometheus expression browser

Now that Prometheus is scraping metrics from a running Minecraft Exporter instance, you can explore those metrics using the Prometheus UI. Navigate to localhost:9090/graph in your browser and use the main expression bar at the top of the page to enter expressions. The expression bar looks like this:

Prometheus expressions browser

Metrics specific to the Minecraft Exporter are prefixed with minecraft_.