GitLab's annual major release is around the corner. Along with a lot of new and exciting features, there will be a few breaking changes. Learn more here.

Commit 90971eb2 authored by Gian M's avatar Gian M
Browse files

added tutorial

parent 7d0d361b
## minetest_server_list_json_live_grafana
## minetest_server_list_json_live_grafana
![](./images/grafana_final_dashboard.png)
A simple Grafana dashboard for displaying server data from Minetest Server List JSON data.
### The JSON of Minetest Server List
This an excerpt of the JSON from `https://servers.minetest.net/list`. You can parse them to get useful data.
```
{
"total": {
"servers": 318,
"clients": 631
},
"total_max": {
"servers": 365,
"clients": 1244
},
"list": [, {
"address": "ka.edgy1.net",
"clients": 9,
"clients_list": ["tommy123", "angeliquee", "sherz", "hacker2121", "K", "master", "jerryscool", "Blackie", "Player37"],
"clients_max": 200,
"creative": false,
"damage": true,
"description": "English / Russian server by KaKoSiK_560, hosted by Edgy1",
"game_time": 4565735,
"gameid": "MultiCraft",
"lag": 0.08999953418970108,
"name": "VineMine [EN/RU]",
"password": false,
"port": 48123,
"proto_max": 39,
"proto_min": 25,
"pvp": true,
"server_id": "multicraft",
"uptime": 192474,
"version": "2.0.0",
"ip": "168.119.147.122",
"update_time": 1613528298.9170504,
"start": 1613335632.029574,
"clients_top": 60,
"dedicated": true,
"rollback": true,
"mapgen": "carpathian",
"privs": "interact, home, shout, zoom, fast",
"can_see_far_names": false,
"mods": ["xban2", "sneak_glitch", "reboot", "mapfix", "irc", "irc_commands", "intllib", "travelnet", "playertools", "hudbars", "homedecor_i18n", "areas", "tpr", "pvp_areas", "markers", "aliases", "worldedit", "worldedit_commands", "worldedit_shortcommands", "worldedit_brush", "junglegrass", "weather", "sfinv", "sethome", "screwdriver", "player_api", "default", "smartshop", "protector", "pkarcs", "nyancat", "no_drowning", "maptools", "lava_test", "laptop", "jail", "signs_lib", "facade", "ehlphabet", "currency", "atm", "cozy", "concrete", "castle_weapons", "biome_lib", "youngtrees", "poisonivy", "molehills", "ferns", "bushes", "better_nametags", "bau_coop", "anvil", "ambience", "cavestuff", "itemframes", "inbox", "walls", "stairs", "farming", "dryplants", "bushes_classic", "give_initial_stuff", "flowers", "flowers_plus", "along_shore", "3dmushrooms", "butterflies", "fire", "tnt", "env_sounds", "dungeon_loot", "vessels", "invisibility", "fireflies", "carts", "moreores", "technic_chests", "boost_cart", "bucket", "bucket_privs", "doors", "xpanes", "creative", "unified_inventory", "unified_inventory_plus", "mail", "worldedit_gui", "u_skins", "bones", "superpick", "boats", "game_commands", "dye", "unifieddyes", "replacer", "mobs", "mobs_balrog", "mobs_animal", "castle_shields", "army", "wool", "moreblocks", "xdecor", "moretrees", "vines", "trunks", "woodsoils", "nature_classic", "glass_stained", "bakedclay", "ethereal", "hbhunger", "extra", "caverealms", "bonemeal", "wine", "3d_armor", "wieldview", "shields", "3d_armor_ui", "3d_armor_stand", "3d_armor_sfinv", "3d_armor_ip", "homedecor_3d_extras", "building_blocks", "castle_tapestries", "lrfurn", "lavalamp", "beds", "homedecor", "myroofs", "plasmascreen", "fake_fire", "chains", "elevator", "spawn", "map", "binoculars"],
"updates": 7627,
"total_clients": 169692,
"pop_v": 22.24885275993182,
"geo_continent": "NA",
"ping": 0.012800455093383789
},
...
```
### Requirements
- [Grafana Server](https://grafana.com/grafana/download)
- [JSON API Plugin](https://grafana.com/grafana/plugins/marcusolsson-json-datasource/installation)
- [Datatable Panel Plugin](https://grafana.com/grafana/plugins/briangann-datatable-panel/installation)
### Steps
#### Installation of the JSON API Plugin:
Open a shell on your local grafana instance and execute the command below as root.
```
# grafana-cli plugins install marcusolsson-json-datasource
```
#### Installation of the Datatable Panel Plugin:
Open a shell on your local grafana instance and execute the command below as root.
```
# grafana-cli plugins install briangann-datatable-panel
```
Sample output:
```
installing briangann-datatable-panel @ 1.0.3
from: https://grafana.com/api/plugins/briangann-datatable-panel/versions/1.0.3/download
into: /var/lib/grafana/plugins
✔ Installed briangann-datatable-panel successfully
Restart grafana after installing plugins . <service grafana-server restart>
```
Restart Grafana server after the installation:
```
# service grafana-server restart
```
#### Adding Data Source
Login to your Grafana, then go to `Configuration > Data Sources > Add data source`.
![](./images/grafana_add_data_source.png)
Select `Others > JSON API`, name it to whatever you want and add the Minetest Server List JSON to the `HTTP URL`.
![](./images/grafana_datasource_minetest.png)
#### Adding New Dashboard
Click the + sign and Create a new dashboard.
![](./images/grafana_add_dashboard.png)
#### Adding Panels
Now you need to add Panel for monitoring general server statistics. Click the `Add panel` icon at the top right position of the screen.
This panel is for listing the current number of online servers and players.
![](./images/grafana_serverlist_panel_add.png)
Under `Query` select `JSON API MINETEST`, the data source from before. Now change the `A` query name to `Servers_Count`. Under `Fields` add this to view the server count, `$.total.servers` and add another field to list display player/clients count, `$.total.clients`.
Click `Visualization` and select `Table`, now click `Apply` and you should see the panel.
We will create two other panels to list player count and player names. You can add as much panel as you like. For the sake of a short tutorial we will only add two.
Adding panel for player count in a server, as an example we will use `VineMine`. Click the `Add panel` icon again.
![](./images/grafana_panel_clients.png)
Under `Query` select `JSON API MINETEST`, the data source from before. Now under the `A` query select `Fields` add this to view the number of online players, `$..list[?(@.name.indexOf("VineMine [EN/RU]") != -1)].clients`.
Click `Visualization` and select `Stat`, now click `Apply` and you should see the panel.
Note: The name `VineMine [EN/RU]` came from the JSON of the official Minetest Server List.
Lastly, adding a panel for the player list (aka. `clients_list` on JSON). Click the `Add panel` icon.
![](./images/grafana_panel_clients_list.png)
Under `Query` select `JSON API MINETEST`, the data source from before. Now under the `A` query select `Fields` add this to view the number of online players, `$..list[?(@.name.indexOf("VineMine [EN/RU]") != -1)].clients_list`.
Click `Visualization` and select `Datatable Panel`, customize it and now click `Apply`. You should now be able to see the new panel.
References:
The command for JSONPath came from `https://stackoverflow.com/questions/47576119/jsonpath-filter-by-value-in-array`. Credit goes to them.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment