cpburnz / minecraft-prometheus-exporter

Prometheus exporter for Minecraft.
MIT License
44 stars 8 forks source link

problem #21

Closed razday closed 2 weeks ago

razday commented 3 months ago

image image

cpburnz commented 3 months ago

Can you confirm you can access Prometheus? That error looks like a problem with Prometheus itself. Prometheus is usually located at http://example.com:9090/graph where example.com is your domain name or IP address. Based on the error message I would expect it to be http://node1.unrealhosting.fr:10006/graph.

razday commented 3 months ago

if I understand correctly I need to link minecraft export to prometheus how to do it? how to display it in grafana you don't have a video tutorial?

cpburnz commented 3 months ago

The default port used by the Prometheus-Exporter mod is 19565 (in world/serverconfig/prometheus_exporter-server.toml). I'm going to assume we're using port 19565.

Now you need to add the Minecraft server to prometheus.yml (usually located at /etc/prometheus/prometheus.yml). It should look something like:

# /etc/prometheus/prometheus.yml
scrape_configs:
  - job_name: minecraft
    static_configs:
      - targets:
          # This needs to point to the Minecraft server running the Prometheus-Exporter mod.
          # If Prometheus runs on the same server as Minecraft, you can replace this with '127.0.0.1:19565'
          - 'node1.unrealhosting.fr:19565'
        labels:
          # The "application" label should indicate the Minecraft server/mod-pack (not to be confused with the server/VM intself).
          # This useful if you're running multiple Minecraft servers on a single VM. 
          application: MyMinecraftModPack
          # The "instance" label typically indicates the server/VM Minecraft is running on.
          # This is useful if you're running multiple Minecraft servers across multiple VMs.
          instance: node1.unrealhosting.fr

Then in Grafana v9 (the dashboard hasn't been updated for Grafana v10 yet), you need to add Prometheus as a data source. The data source URL should be http://node1.unrealhosting.fr:9090 assuming that's where you're running Prometheus.

To summarize how it works: the Prometheus-Exporter mod exposes stats about the Minecraft server. Prometheus periodically fetches those stats from Minecraft. Grafana displays those stats (from Prometheus) as graphs in a dashboard.