Skip to content

Commit

Permalink
prometheus+grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed Sep 22, 2023
1 parent 47e88b9 commit f67e0b9
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 10 deletions.
31 changes: 31 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3'

services:

headlessbot:
image: n0thub/headlessmc:latest
container_name: 'headlessbot'
command: launch "fabric-loader-0.14.22-1.19.4"
ports:
- '127.0.0.1:8080:8080'
volumes:
- '${PWD}/run/mc:/work/.minecraft'
- '${PWD}/run/hmc:/work/HeadlessMC'

grafana:
image: grafana/grafana:latest
container_name: 'grafana'
ports:
- '127.0.0.1:3000:3000'
volumes:
- '${PWD}/grafana/provisioning:/etc/grafana/provisioning'
env_file:
- './grafana/config.env'

prometheus:
image: prom/prometheus:latest
container_name: 'prometheus'
ports:
- '127.0.0.1:9090:9090'
volumes:
- '${PWD}/prometheus.yaml:/etc/prometheus/prometheus.yml:ro'
3 changes: 3 additions & 0 deletions grafana/config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GF_SECURITY_ADMIN_USER=admin
GF_SECURITY_ADMIN_PASSWORD=foobar
GF_USERS_ALLOW_SIGN_UP=false
1 change: 1 addition & 0 deletions grafana/provisioning/access-contro/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apiVersion: 1
1 change: 1 addition & 0 deletions grafana/provisioning/alerting/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apiVersion: 1
9 changes: 9 additions & 0 deletions grafana/provisioning/dashboards/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1

providers:
- name: 'Prometheus'
type: 'file'
disableDeletion: true
options:
path: '/etc/grafana/provisioning/dashboards'
foldersFromFilesStructure: true
142 changes: 142 additions & 0 deletions grafana/provisioning/dashboards/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 2,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "prom42"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-GrYlRd"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "bars",
"fillOpacity": 90,
"gradientMode": "scheme",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 10,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "10.1.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prom42"
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "deaths_total",
"fullMetaSearch": false,
"includeNullMetadata": true,
"instant": false,
"legendFormat": "__auto",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Deaths",
"type": "timeseries"
}
],
"refresh": "",
"schemaVersion": 38,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Bot",
"uid": "bd469455-a5f6-4fb7-bdd2-433d49767ec2",
"version": 1,
"weekStart": ""
}
10 changes: 10 additions & 0 deletions grafana/provisioning/datasources/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: 1

datasources:
- name: 'Prometheus'
uid: 'prom42'
type: 'prometheus'
url: 'http://prometheus:9090'
access: 'proxy'
isDefault: true
editable: false
1 change: 1 addition & 0 deletions grafana/provisioning/notifiers/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apiVersion: 1
1 change: 1 addition & 0 deletions grafana/provisioning/plugins/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apiVersion: 1
9 changes: 9 additions & 0 deletions prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global:
external_labels:
monitor: 'lab'

scrape_configs:

- job_name: 'headlessbot'
static_configs:
- targets: [ 'headlessbot:8080' ]
21 changes: 11 additions & 10 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

set -eu

cd "$(realpath "$(dirname "$(readlink -f "$0")")")"

make clean build

mkdir -p run
cd run

headlessmc() {
docker run -it --rm \
docker run --rm \
-p "127.0.0.1:8080:8080" \
-v "${PWD}/mc:/work/.minecraft" \
-v "${PWD}/hmc:/work/HeadlessMC" \
"n0thub/headlessmc:latest" \
"${@}"
}

cd "$(realpath "$(dirname "$(readlink -f "$0")")")"

make clean build

mkdir -p run
cd run

# msa login
if test ! -f "hmc/auth/.account.json"; then
if test -f "../auth.json"; then
Expand Down Expand Up @@ -58,5 +58,6 @@ done
# install mod
cp ../build/libs/headlessbot.jar mc/mods/

# run client
headlessmc launch "fabric-loader-0.14.22-1.19.4"
# launch bot + monitoring
cd ..
docker compose up --abort-on-container-exit --force-recreate -V

0 comments on commit f67e0b9

Please sign in to comment.