Skip to content

Prometheus

Pavel Erokhin edited this page Nov 9, 2026 · 2 revisions

Prometheus asks the exporter for metrics on every scrape, and the exporter asks WorldAPI. A 15-second interval suits it.

One server

  1. Add a job to prometheus.yml:

    scrape_configs:
      - job_name: minecraft
        scrape_interval: 15s
        static_configs:
          - targets: ["minecraft-exporter:10059"]
            labels: { instance: survival }

    The instance label names the server on the dashboard. Without it, the dashboard shows minecraft-exporter:10059.

  2. Reload Prometheus.

  3. Open Prometheus' “Targets” page: the minecraft job shows “UP”. Query minecraft_up: it returns 1.

Many servers

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.

Scrape timeout

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.

Counters

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.

Clone this wiki locally