docker stop prom
docker stop minio
docker rm prom
docker rm minio
docker network rm homelab
docker network create homelab
mkdir -p /tmp/data
Create individual docker configs
cat << EOF > docker_compose_prometheus.yml
version: '3.7'
services:
prometheus:
image: prom/prometheus:main
container_name: prom
restart: always
user: root:root
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--web.console.libraries=/usr/share/prometheus/console_libraries"
- "--web.console.templates=/usr/share/prometheus/consoles"
- "--storage.tsdb.retention.time=1y"
volumes:
- ~/prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- 10090:9090
networks:
default:
external: true
name: homelab
EOF
cat << EOF > docker_compose_minio.yml
services:
minio:
command: 'server /data --console-address ":9001"'
image: minio/minio
restart: always
environment:
- MINIO_ROOT_PASSWORD=minioadmin
- MINIO_ROOT_USER=minioadmin
- MINIO_API_CORS_ALLOW_ORIGIN=*
- MINIO_PROMETHEUS_AUTH_TYPE=public
- MINIO_PROMETHEUS_URL="http://prom:10090"
- MINIO_PROMETHEUS_JOB_ID=minio-job
- MINIO_LOG_LEVEL=debug
volumes:
- '/tmp/data:/data'
container_name: minio
ports:
- 10001:9001
- 10000:9000
expose:
- 10001
- 10000
networks:
default:
external: true
name: homelab
EOF
docker compose -f docker_compose_minio.yml up -d
docker compose -f docker_compose_prometheus.yml up -d
Obtain prometheus scrape config from mc
docker exec -it minio /bin/bash
bash-5.1# curl http://prom:9090/-/healthy
Prometheus Server is Healthy.
bash-5.1# mc alias set home http://minio:9000 minioadmin minioadmin
mc: Configuration written to `/tmp/.mc/config.json`. Please update your access credentials.
mc: Successfully created `/tmp/.mc/share`.
mc: Initialized share uploads `/tmp/.mc/share/uploads.json` file.
mc: Initialized share downloads `/tmp/.mc/share/downloads.json` file.
Added `home` successfully.
bash-5.1# mc admin info home
● minio:9000
Uptime: 6 minutes
Version: 2024-05-10T01:41:38Z
Network: 1/1 OK
Drives: 1/1 OK
Pool: 1
Pools:
1st, Erasure sets: 1, Drives per erasure set: 1
1 drive online, 0 drives offline, EC:0
mc admin prometheus generate home
exit
cat << EOF > prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: minio-job
bearer_token: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJwcm9tZXRoZXVzIiwic3ViIjoibWluaW9hZG1pbiIsImV4cCI6NDg2OTIyNDA2M30.ruZjWqdaxHjObkeuLczEQhy24wg6U66dJTruOHvUnOBX5unAwJC9jQ7x1UhpCadvNEQLxzL6iFFzE2buNs80zw
metrics_path: /minio/v2/metrics/cluster
scheme: http
static_configs:
- targets: ['minio:9000']
EOF
Restart prometheus with config
curl http://console-3347.minio.training:10090/metrics | grep "prometheus_target_metadata_cache_bytes"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0# HELP prometheus_target_metadata_cache_bytes The number of bytes that are currently used for storing metric metadata in the cache
# TYPE prometheus_target_metadata_cache_bytes gauge
prometheus_target_metadata_cache_bytes{scrape_job="minio-job"} 4065
100 67557 0 67557 0 0 779k 0 --:--:-- --:--:-- --:--:-- 785k