diff --git a/dashboards/mc-monitor.json b/dashboards/mc-monitor.json new file mode 100644 index 0000000..1d529af --- /dev/null +++ b/dashboards/mc-monitor.json @@ -0,0 +1,467 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 1, + "iteration": 1641155749460, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "0": { + "color": "red", + "index": 1, + "text": "Down" + }, + "1": { + "color": "green", + "index": 0, + "text": "Up" + } + }, + "type": "value" + } + ], + "max": 1, + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 100 + } + ] + }, + "unit": "bool_yes_no" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 4, + "x": 0, + "y": 0 + }, + "id": 2, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "8.3.3", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "exemplar": true, + "expr": "minecraft_status_healthy{server_host=\"$server\",server_version=~\".+\"}", + "interval": "", + "legendFormat": "{{server_host}}", + "refId": "A" + } + ], + "title": "Healthy", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "online" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 100 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "max" + }, + "properties": [ + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 20, + "x": 4, + "y": 0 + }, + "id": 4, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "exemplar": true, + "expr": "minecraft_status_players_online_count{server_host=\"$server\"}", + "interval": "", + "legendFormat": "online", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "exemplar": true, + "expr": "minecraft_status_players_max_count{server_host=\"$server\"}", + "hide": false, + "interval": "", + "legendFormat": "max", + "refId": "B" + } + ], + "title": "Players", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "cores", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 7 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "hidden", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "exemplar": true, + "expr": "rate(container_cpu_user_seconds_total{container_label_com_docker_compose_service=\"$server\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "{{container_label_com_docker_compose_service}}", + "refId": "A" + } + ], + "title": "Minecraft Service - CPU Usage", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 7 + }, + "id": 7, + "options": { + "legend": { + "calcs": [], + "displayMode": "hidden", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "exemplar": true, + "expr": "container_memory_usage_bytes{container_label_com_docker_compose_service=\"$server\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{container_label_com_docker_compose_service}}", + "refId": "A" + } + ], + "title": "Minecraft Service - Memory Usage", + "type": "timeseries" + } + ], + "refresh": "1m", + "schemaVersion": 34, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "mc", + "value": "mc" + }, + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "definition": "label_values(server_host)", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "server", + "options": [], + "query": { + "query": "label_values(server_host)", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-15m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "MC Monitor", + "uid": "PpzSgJAnk", + "version": 3, + "weekStart": "" +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c674df5..5872330 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,19 +39,41 @@ services: volumes: - ../patata-data:/data #- ./simple-discord-bot.toml:/data/config/simple-discord-bot.toml - telegraf: - container_name: mc-telegraf-patata - image: telegraf:1.13 - ports: - - 8094:8094 - volumes: - - ./telegraf.conf:/etc/telegraf/telegraf.conf:ro monitor: - container_name: mc-monitor-patata - build: - context: ../.. - command: gather-for-telegraf + image: itzg/mc-monitor + command: export-for-prometheus environment: - GATHER_INTERVAL: 10s - GATHER_TELEGRAF_ADDRESS: telegraf:8094 - GATHER_SERVERS: mc-forge-patata: \ No newline at end of file + EXPORT_SERVERS: mc + DEBUG: "true" + depends_on: + - mc + cadvisor: + image: gcr.io/cadvisor/cadvisor:v0.47.1 + ports: + - "8180:8080" + volumes: + - /:/rootfs:ro + - /var/run:/var/run:rw + - /sys:/sys:ro + - /var/lib/docker/:/var/lib/docker:ro + prometheus: + image: prom/prometheus + volumes: + - ./prometheus.yml:/etc/prometheus/prometheus.yml + - ../prometheus-tsdb:/prometheus + depends_on: + - monitor + grafana: + image: grafana/grafana-oss:${GRAFANA_VERSION:-8.3.3} + ports: + - "3000:3000" + volumes: + - ../grafana-lib:/var/lib/grafana + - ./grafana/provisioning:/etc/grafana/provisioning + - ./dashboards:/etc/grafana/dashboards + depends_on: + - prometheus +volumes: + patata-data: {} + prometheus-tsdb: {} + grafana-lib: {} \ No newline at end of file diff --git a/grafana/provisioning/dashboards/etc.yml b/grafana/provisioning/dashboards/etc.yml new file mode 100644 index 0000000..95ec84e --- /dev/null +++ b/grafana/provisioning/dashboards/etc.yml @@ -0,0 +1,10 @@ +apiVersion: 1 + +providers: + - name: 'etc files' + type: file + disableDeletion: false + allowUiUpdates: true + options: + path: /etc/grafana/dashboards + foldersFromFilesStructure: true \ No newline at end of file diff --git a/grafana/provisioning/datasources/prom.yml b/grafana/provisioning/datasources/prom.yml new file mode 100644 index 0000000..d96153a --- /dev/null +++ b/grafana/provisioning/datasources/prom.yml @@ -0,0 +1,7 @@ +apiVersion: 1 + +datasources: + - name: Prometheus + type: prometheus + access: proxy + url: http://prometheus:9090 diff --git a/prometheus.yml b/prometheus.yml new file mode 100644 index 0000000..2fc108c --- /dev/null +++ b/prometheus.yml @@ -0,0 +1,9 @@ +global: + scrape_interval: 30s +scrape_configs: + - job_name: mc-monitor + static_configs: + - targets: + - monitor:8080 + - targets: + - cadvisor:8080 \ No newline at end of file