From e0e0d626f9b41e7c055fb6a4bfbdc8a375e5c7e1 Mon Sep 17 00:00:00 2001 From: Jacob Babor Date: Wed, 10 Jul 2024 01:13:16 -0500 Subject: [PATCH] Add Minecraft monitoring! This also fixes some duplicate alert structures we saw earlier --- .../tasks/game/minecraft-createfarming.yml | 6 ++++++ roles/prometheus/templates/prometheus.yml.j2 | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/playbooks/tasks/game/minecraft-createfarming.yml b/playbooks/tasks/game/minecraft-createfarming.yml index fbf7715..c066c63 100644 --- a/playbooks/tasks/game/minecraft-createfarming.yml +++ b/playbooks/tasks/game/minecraft-createfarming.yml @@ -16,6 +16,12 @@ - "25565:25565/tcp" - "25565:25565/udp" - "24454:24454/udp" + # Prometheus exporter for Forge + # https://www.curseforge.com/minecraft/mc-mods/prometheus-exporter + #- "19565:19565/tcp" + # Prometheus exporter for Fabric + # https://modrinth.com/mod/fabricexporter + - "19565:25585/tcp" volumes: - /data/minecraft/createfarming:/data tags: [ docker, minecraft, create, createfarming ] diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 index 241ab36..2f0a706 100644 --- a/roles/prometheus/templates/prometheus.yml.j2 +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -34,6 +34,7 @@ scrape_configs: static_configs: - targets: {% for host in groups['tags_nagios'] %} +{% set vars = hostvars[host] %} {% for service in vars.services %} {% for tag in service.tags %} {# #} @@ -63,6 +64,25 @@ scrape_configs: static_configs: - targets: ['blackbox:9115'] + # This job manages Minecraft servers, when we have them + - job_name: "minecraft" + static_configs: + - targets: +{% for host in groups['tags_nagios'] %} +{% set vars = hostvars[host] %} +{% for service in vars.services %} +{% for tag in service.tags %} +{# #} +{% if tag.slug == "nagios-checkminecraft" %} +{% for port in service.ports %} + - "{{ host }}:{{ port }}" +{% endfor %} +{% endif %} +{# #} +{% endfor %} +{% endfor %} +{% endfor %} + # These two jobs are included for every node in our inventory - job_name: "node-exporter" static_configs: