diff options
| author | Max Audron <audron@cocaine.farm> | 2025-08-01 02:01:20 +0200 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2025-08-01 02:01:20 +0200 |
| commit | ad91208ae1cea92566ad03d3b4cdd68f0e71c55a (patch) | |
| tree | f82b0f7637ed28a9f7d1afb4214563b2e7331d80 /modules | |
| parent | more monitoring & scrape config shortcuts (diff) | |
add minecraft prometheus exporter
Diffstat (limited to '')
| -rw-r--r-- | modules/games/default.nix | 35 | ||||
| -rw-r--r-- | modules/monitoring/default.nix | 2 |
2 files changed, 34 insertions, 3 deletions
diff --git a/modules/games/default.nix b/modules/games/default.nix index fee8e34..8befc83 100644 --- a/modules/games/default.nix +++ b/modules/games/default.nix @@ -55,6 +55,7 @@ minecraft_mods = { image = "itzg/minecraft-server"; autoStart = true; + extraOptions = [ "--network=host" ]; environment = { EULA = "true"; TYPE = "FABRIC"; @@ -62,15 +63,43 @@ SEED = "-3691007458655063350"; INIT_MEMORY = "1G"; MAX_MEMORY = "4G"; + + OVERRIDE_SERVER_PROPERTIES = "false"; }; - ports = [ - "25566:25565" - ]; volumes = [ "/var/lib/minecraft_mods:/data" ]; }; }; + systemd.services.prometheus-minecraft-exporter = + let exporter = pkgs.callPackage ../../pkgs/prometheus-minecraft-exporter {}; + in { + description = "minecraft prometheus exporter"; + enable = true; + + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" "podman-minecraft_mods.service" ]; + + serviceConfig = { + ExecStart = (lib.concatStringsSep " " ([ + "${exporter}/bin/minecraft-exporter" + "--web.listen-address=:9150" + "--mc.world=/var/lib/minecraft_mods/world" + "--mc.name-source=mojang" + "--mc.mod-server-stats=fabric" + "--web.disable-exporter-metrics" + ])); + EnvironmentFile = "/etc/secrets/minecraft_rcon.env"; + }; + }; + + secrets = { + minecraft = { + source = ../../secrets/minecraft_rcon.env; + dest = "/etc/secrets/minecraft_rcon.env"; + }; + }; + networking.firewall.allowedTCPPorts = [ 25566 ]; } diff --git a/modules/monitoring/default.nix b/modules/monitoring/default.nix index afcffa5..fe49c00 100644 --- a/modules/monitoring/default.nix +++ b/modules/monitoring/default.nix @@ -35,6 +35,8 @@ in { (mkScrapeConfig "garage" [ "fra01" "nyc01" "sin01" ] 3903) (mkScrapeConfig "pdns" [ "ettves" "fra01" "nyc01" "sin01" ] 8081) + + (mkScrape "minecraft" [ "ettves:25585" "ettves:9150" ]) ]; }; |
