From 18bb111843163e73ee97cf133e1f42652d22e8be Mon Sep 17 00:00:00 2001 From: Hermes Agent service account Date: Sun, 19 Jul 2026 14:53:36 -0500 Subject: [PATCH] feat(minecraft): add Prometheus metrics + Grafana dashboard - minecraft-prometheus-exporter v3.1.2 plugin (port 9225) - ServiceMonitor for Prometheus scraping - Grafana dashboard ConfigMap (ID 20659, Minecraft server stats) - metrics port added to Service and Deployment containerPorts --- cluster/applications/minecraft/configmap.yaml | 5 + .../applications/minecraft/deployment.yaml | 3 + .../minecraft/grafana-dashboard.yaml | 699 ++++++++++++++++++ cluster/applications/minecraft/service.yaml | 4 + .../minecraft/servicemonitor.yaml | 23 + 5 files changed, 734 insertions(+) create mode 100644 cluster/applications/minecraft/grafana-dashboard.yaml create mode 100644 cluster/applications/minecraft/servicemonitor.yaml diff --git a/cluster/applications/minecraft/configmap.yaml b/cluster/applications/minecraft/configmap.yaml index 3c6d789..40e75a3 100644 --- a/cluster/applications/minecraft/configmap.yaml +++ b/cluster/applications/minecraft/configmap.yaml @@ -39,3 +39,8 @@ data: ENABLE_RCON: "true" RCON_PORT: "25575" + # Plugin auto-download — minecraft-prometheus-exporter for Grafana metrics + # v3.1.2: https://github.com/sladkoff/minecraft-prometheus-exporter + # Exposes /metrics on port 9225 (HTTP, Prometheus scrape target) + PLUGINS: "https://github.com/sladkoff/minecraft-prometheus-exporter/releases/download/v3.1.2/minecraft-prometheus-exporter-3.1.2.jar" + diff --git a/cluster/applications/minecraft/deployment.yaml b/cluster/applications/minecraft/deployment.yaml index c842daa..8594f80 100644 --- a/cluster/applications/minecraft/deployment.yaml +++ b/cluster/applications/minecraft/deployment.yaml @@ -48,6 +48,9 @@ spec: - name: rcon containerPort: 25575 protocol: TCP + - name: metrics + containerPort: 9225 + protocol: TCP env: - name: EULA value: "TRUE" diff --git a/cluster/applications/minecraft/grafana-dashboard.yaml b/cluster/applications/minecraft/grafana-dashboard.yaml new file mode 100644 index 0000000..8d9059b --- /dev/null +++ b/cluster/applications/minecraft/grafana-dashboard.yaml @@ -0,0 +1,699 @@ +--- +# Grafana dashboard — Minecraft server stats (ID 20659) +# Source: https://grafana.com/grafana/dashboards/20659 +# Plugin: sladkoff/minecraft-prometheus-exporter v3.1.2 +apiVersion: v1 +kind: ConfigMap +metadata: + name: dashboard-minecraft + namespace: monitoring + labels: + grafana_dashboard: "1" + app.kubernetes.io/name: minecraft + app.kubernetes.io/component: grafana-dashboard +data: + minecraft-server-stats.json: | + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Modern dashboard for minecraft-prometheus-exporter\r\nhttps://github.com/Joshi425/minecraft-exporter", + "editable": true, + "fiscalYearStartMonth": 0, + "gnetId": 20659, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 16, + "panels": [], + "title": "Server stats", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Time" + }, + "properties": [ + { + "id": "displayName", + "value": "Time" + }, + { + "id": "custom.align" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/Value/" + }, + "properties": [ + { + "id": "unit", + "value": "short" + }, + { + "id": "decimals", + "value": 2 + }, + { + "id": "custom.align" + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 4, + "x": 0, + "y": 1 + }, + "id": 9, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "player_online", + "instant": true, + "legendFormat": "{{player}}", + "refId": "A" + } + ], + "title": "Players", + "transformations": [ + { + "id": "merge", + "options": { + "reducers": [] + } + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 25, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": 3600000, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 10, + "x": 4, + "y": 1 + }, + "id": 13, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "disableTextWrap": false, + "editorMode": "builder", + "exemplar": false, + "expr": "dim_ticktime", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{dimension_id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Time per tick", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-RdYlGr" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 27, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": 3600000, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "max": 20, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 10, + "x": 14, + "y": 1 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "disableTextWrap": false, + "editorMode": "builder", + "exemplar": false, + "expr": "dim_tps", + "fullMetaSearch": false, + "includeNullMetadata": false, + "instant": false, + "legendFormat": "{{ dimension_id }}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Ticks per second", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 10 + }, + "id": 15, + "panels": [], + "title": "Player & entity metrics", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [] + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 13, + "x": 0, + "y": 11 + }, + "id": 14, + "options": { + "legend": { + "displayMode": "table", + "placement": "right", + "showLegend": true, + "values": [ + "value" + ] + }, + "pieType": "donut", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "entities", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{entity}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Entities loaded", + "type": "piechart" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [] + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 11, + "x": 13, + "y": 11 + }, + "id": 18, + "options": { + "legend": { + "displayMode": "table", + "placement": "right", + "showLegend": true, + "values": [ + "value", + "percent" + ] + }, + "pieType": "pie", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "player_score", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{player}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Players score", + "type": "piechart" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-BlPu" + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 13, + "x": 0, + "y": 19 + }, + "id": 3, + "options": { + "displayMode": "gradient", + "maxVizHeight": 300, + "minVizHeight": 16, + "minVizWidth": 8, + "namePlacement": "top", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "auto", + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "player_playtime", + "legendFormat": "{{ player }}", + "range": true, + "refId": "A" + } + ], + "title": "Play time", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-BlPu" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 11, + "x": 13, + "y": 19 + }, + "id": 17, + "options": { + "displayMode": "gradient", + "maxVizHeight": 300, + "minVizHeight": 16, + "minVizWidth": 8, + "namePlacement": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "auto", + "valueMode": "color" + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "player_advancements", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{player}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Advancements made", + "type": "bargauge" + } + ], + "refresh": "10s", + "schemaVersion": 39, + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Minecraft server stats [Prometheus]", + "uid": "LhW0bV0Wz", + "version": 15, + "weekStart": "" + } diff --git a/cluster/applications/minecraft/service.yaml b/cluster/applications/minecraft/service.yaml index dd9cfe6..8ffa536 100644 --- a/cluster/applications/minecraft/service.yaml +++ b/cluster/applications/minecraft/service.yaml @@ -33,3 +33,7 @@ spec: port: 25575 targetPort: 25575 protocol: TCP + - name: metrics + port: 9225 + targetPort: 9225 + protocol: TCP diff --git a/cluster/applications/minecraft/servicemonitor.yaml b/cluster/applications/minecraft/servicemonitor.yaml new file mode 100644 index 0000000..2fc3d22 --- /dev/null +++ b/cluster/applications/minecraft/servicemonitor.yaml @@ -0,0 +1,23 @@ +--- +# ServiceMonitor — tells Prometheus to scrape minecraft-prometheus-exporter +# Plugin exposes /metrics on port 9225 (HTTP) +# Dashboard: https://grafana.com/grafana/dashboards/20659 +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: minecraft + namespace: minecraft + labels: + app.kubernetes.io/name: minecraft + app.kubernetes.io/component: papermc + # Label required for kube-prometheus-stack to discover this ServiceMonitor + release: monitoring +spec: + selector: + matchLabels: + app.kubernetes.io/name: minecraft + app.kubernetes.io/component: papermc + endpoints: + - port: metrics + path: /metrics + interval: 15s