feat: add basic prometheus/grafana setup

This commit is contained in:
gmega 2025-06-23 19:12:45 -03:00
parent 19f87a2298
commit 7df3990968
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18
3 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,45 @@
version: '3.8'
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./targets:/etc/prometheus/targets:ro
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
extra_hosts:
- "host.docker.internal=${HOST_IP}"
restart: unless-stopped
grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/dashboards:/var/lib/grafana/dashboards
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_DISABLE_LOGIN_FORM=true
- GF_INSTALL_PLUGINS=grafana-clock-panel
extra_hosts:
- "host.docker.internal=${HOST_IP}"
restart: unless-stopped
depends_on:
- prometheus
volumes:
prometheus_data:
grafana_data:

14
dashboard/launch.sh Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e -o pipefail
if [ "$OSTYPE" = "darwin" ]; then
HOST_IP="host-gateway"
elif [ "$OSTYPE" = "linux-gnu" ]; then
HOST_IP=$(hostname -I | cut -d " " -f 1)
else
echo "Unsupported OS: $OSTYPE"
exit 1
fi
export HOST_IP
docker compose up "$@"

19
dashboard/prometheus.yml Normal file
View File

@ -0,0 +1,19 @@
# Prometheus configuration file
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['host.docker.internal:9090']
- job_name: 'codex-metrics'
file_sd_configs:
- files:
- '/etc/prometheus/targets/*.json'
refresh_interval: 1s
scrape_interval: 1s
metrics_path: '/metrics'
scheme: http