Difference between revisions of "Server Metrics using Prometheus"

From Minetest Wiki
Jump to navigation Jump to search
(Created page with "<syntaxhighlight lang="bash">cd /tmp git clone --recursive https://github.com/jupp0r/prometheus-cpp mkdir prometheus-cpp/build cd prometheus-cpp/build cmake .. -DCMAKE_INSTALL...")
 
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
 +
Prometheus is an "open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach".
 +
 +
Minetest has built-in support for prometheus, allowing you to see metrics about your server - such as player count and performance information.
 +
 +
Here are some examples of Grafana dashboards created using Prometheus:
 +
 +
- [https://monitor.rubenwardy.com/d/9TgIegyGk/ctf monitor.rubenwardy.com]
 +
- [https://monitoring.minetest.land/ monitoring.minetest.land] (note: this contains heavy mondifications)
 +
 +
== Using Prometheus in Minetest ==
 +
 +
=== Get or build the prometheus-cpp library ===
 +
 +
You may be able to find prometheus-cpp in your distro's package manager.
 +
Otherwise, you'll need to build it and make it available to Minetest.
 +
 +
Here's how you do that on Linux:
 +
 
<syntaxhighlight lang="bash">cd /tmp
 
<syntaxhighlight lang="bash">cd /tmp
 
git clone --recursive https://github.com/jupp0r/prometheus-cpp
 
git clone --recursive https://github.com/jupp0r/prometheus-cpp
Line 4: Line 23:
 
cd prometheus-cpp/build
 
cd prometheus-cpp/build
 
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=0
 
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=0
make -j2
+
make -j$(nproc)
 
sudo make install</syntaxhighlight>
 
sudo make install</syntaxhighlight>
  
 +
=== Build Minetest ===
 +
 +
Now, you need build minetest with Prometheus enabled
 +
 +
<syntaxhighlight lang="bash">cmake . -DENABLE_PROMETHEUS=1
 +
make -j$(nproc)</syntaxhighlight>
 +
 +
=== Configure prometheus ===
 +
 +
Prometheus will make HTTP requests to Minetest's prometheus-cpp library to get the metrics.
 +
 +
You can set the prometheus listen address by assigning an IP:PORT in the minetest.conf:
 +
 +
<code><pre>prometheus_listener_address = 127.0.0.1:30000</pre></code>
 +
 +
== Grafana ==
 +
 +
You can link up Prometheus to Grafana to make nice web graphs. For example:
 +
[https://monitor.rubenwardy.com/d/r6cCl68mk/minetest-servers monitor.rubenwardy.com]
  
<syntaxhighlight lang="lua">noise_params = {
+
To do: example layouts
    offset  = 0,
 
    scale  = 1,
 
    spread  = {x=250, y=250, z=250},
 
    seed    = 12345,
 
    octaves = 3,
 
    persist = 0.6,
 
    lacunarity = 2,
 
    flags = "defaults",
 
}</syntaxhighlight>
 

Latest revision as of 01:53, 31 August 2022

Prometheus is an "open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach".

Minetest has built-in support for prometheus, allowing you to see metrics about your server - such as player count and performance information.

Here are some examples of Grafana dashboards created using Prometheus:

- monitor.rubenwardy.com - monitoring.minetest.land (note: this contains heavy mondifications)

Using Prometheus in Minetest

Get or build the prometheus-cpp library

You may be able to find prometheus-cpp in your distro's package manager. Otherwise, you'll need to build it and make it available to Minetest.

Here's how you do that on Linux:

cd /tmp
git clone --recursive https://github.com/jupp0r/prometheus-cpp
mkdir prometheus-cpp/build
cd prometheus-cpp/build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=0
make -j$(nproc)
sudo make install

Build Minetest

Now, you need build minetest with Prometheus enabled

cmake . -DENABLE_PROMETHEUS=1
make -j$(nproc)

Configure prometheus

Prometheus will make HTTP requests to Minetest's prometheus-cpp library to get the metrics.

You can set the prometheus listen address by assigning an IP:PORT in the minetest.conf:

prometheus_listener_address = 127.0.0.1:30000

Grafana

You can link up Prometheus to Grafana to make nice web graphs. For example: monitor.rubenwardy.com

To do: example layouts