Repository navigation
Prometheus
Prometheus asks the exporter for metrics on every scrape, and the exporter asks WorldAPI. A 15-second interval suits it.
-
Add a job to
prometheus.yml:scrape_configs: - job_name: minecraft scrape_interval: 15s static_configs: - targets: ["minecraft-exporter:10059"] labels: { instance: survival }
The
instancelabel names the server on the dashboard. Without it, the dashboard showsminecraft-exporter:10059. -
Reload Prometheus.
-
Open Prometheus' “Targets” page: the
minecraftjob shows “UP”. Queryminecraft_up: it returns1.
With a targets file, Prometheus asks /probe for each server by name:
scrape_configs:
- job_name: minecraft
metrics_path: /probe
static_configs:
- targets: [survival, creative]
relabel_configs:
- { source_labels: [__address__], target_label: __param_target }
- { source_labels: [__param_target], target_label: instance }
- { target_label: __address__, replacement: "minecraft-exporter:10059" }The relabeling turns each name into ?target=<name>, uses it as the instance label, and sends the request to the exporter. A name the file doesn't list answers 404.
/probe leaves out the exporter's own metrics: the Go runtime, the process, minecraft_exporter_build_info, and minecraft_exporter_request_errors_total. To keep them, add a second job that scrapes /metrics.
Prometheus' default scrape timeout is 10 seconds, the same as EXPORTER_TIMEOUT. The exporter reads Prometheus' timeout from the request and finishes half a second before it, so a slow WorldAPI costs a few metrics instead of the whole scrape.
Event and console counters count from the exporter's start, the way Prometheus counters do: use rate() and increase() on them. Player statistics come from the game's own lifetime counters, so they keep their values across restarts of the exporter.
Next: Grafana.
For server owners
For developers