From aa8d155d9d6ee8fd98c89c6f705f59600f9ca187 Mon Sep 17 00:00:00 2001 From: Gilles Mouchet Date: Mon, 9 Jun 2025 07:53:44 +0200 Subject: [PATCH] v1.1.0 --- .env.dist | 11 ++++-- README.md | 83 +++++++++++++++++++++++++++++++++++++++++-- config/default.conf | 6 +++- config/prometheus.yml | 18 ++++++++++ docker-compose.yaml | 70 ++++++++++++++++++++++++++---------- 5 files changed, 163 insertions(+), 25 deletions(-) create mode 100644 config/prometheus.yml diff --git a/.env.dist b/.env.dist index 36dd6e4..84c2df5 100644 --- a/.env.dist +++ b/.env.dist @@ -7,11 +7,13 @@ COMPOSE_PROJECT_NAME=gmo-loki # certificats path (ex: /home/docker/certs) PRX_CERTS_DIR= # nginx default.conf file path (ex: /home/docker/nginx) -PRX_NGINX_CONF_DIR= +PRX_NGINX_CONF_DIR= #------------------------------------------------ # minio -# path where minio data will be stored (ex: /home/docker/mino) +# path where minio data will be stored (ex: /home/docker/minio) MINIO_DATA_ROOT_DIR= +# path where mino client will be stored (ex: /home/docker/minio-cli) +MINIO_CONF_CLI_DIR= # user MINIO_ACCESS_KEY=minio # passord @@ -29,3 +31,8 @@ GF_VOLUME_DIR= # url redirect (ex: https://docker1.gmolab.net/grafana/) GF_ROOT_URL=/grafana/ #------------------------------------------------ +# prometheus +# conf dir prometheus.yml +PROM_CONF_DIR= +# data dir (ex: /home/docker/prometheus-data) +PROM_DATA_DIR= diff --git a/README.md b/README.md index cb19203..5835f7d 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This dokcer run stack grafana, loki, promtail, minio | -proxy-1 | `https://` | nginx proxy | -minio-1 | UI: `https:///minio/ui`
API: `http://127.0.0.1:9000`| container minio server UI and API | | -grafana-1 | `https:///grafana` | grafana | +| -minio-cli-1 | - | client minio | ## Requirements ### Certificats Create a folder named `/home/docker/certs` and copy your certificates into it. @@ -34,22 +35,79 @@ Create the folder where the minio data will be stored sudo mkdir -p /home/docker/minio ``` +### Minio client +Create the folder where the minio client comfig will be stored +```bash +sudo mkdir -p /home/docker/minio-cli +``` + ### Grafana Create the folder where the grafana data will be stored ```bash sudo mkdir -p /home/docker/grafana ``` +### Prometheus +Create the folder where the grafana data will be stored +```bash +sudo mkdir -p /home/docker/prometheus +``` +Create the folder where the prometheus data will be stored +```bash +sudo mkdir -p /home/docker/prometheus-data +``` + ## Run ```bash docker compose up -d ``` +## Config +### Minio client +Create an alias +```bash +docker exec -it -minio-cli-1 /bin/sh -c "mc alias set myminio http://minio:9000 " +``` + +Create prometheus metrics job +```bash +docker exec -it -minio-cli-1 /bin/sh -c "mc admin prometheus generate myminio" +``` + +Copy the output into prometheus.yml +```yaml +scrape_configs: +- job_name: minio-job + bearer_token: eyJhbGciOiJIUzUxMiIs..InR5cCI6IkpXVCJ9 + metrics_path: /minio/v2/metrics/cluster + scheme: http + static_configs: + - targets: ['minio:9000'] +``` + +Restart prometheus +```bash +docker compose restart prometheus +``` + +Add dashboard ***13502 - MinIO Dashboard*** to grafana + +### Prometheus +#### grafana source +`http://prometheus:9090` + +#### grafana dashboard +3662 - Prometheus 2.0 Overview + +### Node exporter +#### grafana dashboard +1860 - Node Exporter Full + ## Access **dns-tools** ```bash -docker exec -it dns-tools /bin/bash +docker exec -it -dns-tools /bin/bash ``` ```bash dig minio-server @@ -57,12 +115,19 @@ ping minio-server nslookup minio-server ``` -**Minio console** +**minio** `https:///minio/ui/` -**Grafana** +**minio-cli** +```bash +docker exec -it -minio-cli-1 /bin/sh +``` +**grafana** `https:///grafana/` +**prometheus** +`http://:9090` + ## Sources ### Minio * https://github.com/Anagraph/minio-docker-config/blob/master/docker-compose.yaml @@ -72,7 +137,19 @@ nslookup minio-server * https://grafana.com/docs/loki/latest/setup/install/docker/ * https://grafana.com/tutorials/run-grafana-behind-a-proxy/ +### Prometheus +* https://mxulises.medium.com/simple-prometheus-setup-on-docker-compose-f702d5f98579 + ## Changelog +### [1.1.0] - 2025-06-09 +#### Added +- prometheus container +- node exporter container +- grafana dashboard + - 1860 - Node Exporter Full + - 3662 - Prometheus 2.0 Overview + - 13502 - MinIO Dashboard + ### [1.0.0] - 2025-06-08 #### Added - init docker container diff --git a/config/default.conf b/config/default.conf index 7d36e4f..b5de365 100644 --- a/config/default.conf +++ b/config/default.conf @@ -56,5 +56,9 @@ server { chunked_transfer_encoding off; proxy_pass http://minio:9001/; - } + } +# location /prometheus/ { +# #rewrite /prometheus/(.*) /$1 break; +# proxy_pass http://prometheus:9090/; +# } } diff --git a/config/prometheus.yml b/config/prometheus.yml new file mode 100644 index 0000000..bfb7a24 --- /dev/null +++ b/config/prometheus.yml @@ -0,0 +1,18 @@ +global: + scrape_interval: 10s + +scrape_configs: + - job_name: prometheus + static_configs: + - targets: + - prometheus:9090 + - job_name: node + static_configs: + - targets: + - node-exporter:9100 + - job_name: minio-job + bearer_token: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJwcm9tZXRoZXVzIiwic3ViIjoiYWRtaW4iLCJleHAiOjQ5MDI5NzQ1Mzh9.BuzZdu0W1TBfolWIMUPYhuRHuAFfrHuLw0CYMCK3NhqWzmx9u_P6uu3rJl4R71JlUhTDU31U3q4-mh9Ev7aOjQ + metrics_path: /minio/v2/metrics/cluster + scheme: http + static_configs: + - targets: ['minio:9000'] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 60e5e5e..f6cbfa4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,7 +3,7 @@ networks: name: loki-net # replace the default domain .loki-net services: - # init container to change permissions of the mounted directory. + #------- init container to change permissions of the mounted directory. init: image: busybox user: root @@ -11,15 +11,17 @@ services: /bin/sh -c " chown 472:root /var/lib/grafana; chown 101:root /etc/nginx/conf.d/default.conf; + chown nobody:nobody /prometheus -R; exit 0; " volumes: - '${GF_VOLUME_DIR}:/var/lib/grafana' - '${PRX_NGINX_CONF_DIR}/default.conf:/etc/nginx/conf.d/default.conf' + - '${PROM_DATA_DIR}:/prometheus' networks: - loki - # container with tools dns (nslookup, tcptraceroute, etc). Use just for debug + #------- container with tools dns (nslookup, tcptraceroute, etc). Use just for debug # dns-tools: # image: jonlabelle/network-tools # command: tail -f /dev/null @@ -27,6 +29,8 @@ services: # tty: true # networks: # - loki + + #-------proxy (nginx) proxy: image: nginxinc/nginx-unprivileged volumes: @@ -37,11 +41,12 @@ services: #- "80:8080" networks: - loki - restart: unless-stopped -# - # minio server service + restart: always + + #------- minio server service minio: - image: minio/minio + #image: minio/minio + image: minio/minio:RELEASE.2025-03-12T18-04-18Z restart: always volumes: - ${MINIO_DATA_ROOT_DIR}:/data @@ -56,24 +61,30 @@ services: networks: - loki - # service not necessary, used here to explain how to interact from the container -# minio-client: + #------- minio client +# minio-cli: # image: minio/mc # # insure that the server container is running before building the client # depends_on: # - minio # entrypoint: > -# /bin/sh -c " -# /usr/bin/mc admin info play; -# /usr/bin/mc alias set myminio http://minio:9000 ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY}; -# /usr/bin/mc mb myminio/test-bucket; -# /usr/bin/mc mb myminio/loki-1; -# echo 'my content' > myfile.txt; -# /usr/bin/mc cp myfile.txt myminio/test-bucket; -# exit 0; -# " +# /bin/sh -c "tail -f /dev/null" +# #/usr/bin/mc admin info play; +# #/usr/bin/mc alias set myminio http://minio:9000 ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY}; +# #/usr/bin/mc admin prometheus generate myminio +# ##/usr/bin/mc mb myminio/test-bucket; +# ##/usr/bin/mc mb myminio/loki-1; +# ##echo 'my content' > myfile.txt; +# ##/usr/bin/mc cp myfile.txt myminio/test-bucket; +# #exit 0; +# #" +# volumes: +# - ${MINIO_CONF_CLI_DIR}/.mc:/root/.mc +# restart: unless-stopped # networks: # - loki + + #------- grafana grafana: image: grafana/grafana-enterprise ports: @@ -88,8 +99,29 @@ services: restart: unless-stopped networks: - loki + + #------- prometheus + prometheus: + image: prom/prometheus + volumes: + - ${PROM_CONF_DIR}/prometheus.yml:/etc/prometheus/prometheus.yml + - ${PROM_DATA_DIR}:/prometheus + ports: + - 9090:9090 + restart: unless-stopped + networks: + - loki -volumes: - grafana-storage: + #------- node-exporter + node-exporter: + image: prom/node-exporter + networks: + - loki + ports: + - 9100:9100 + restart: unless-stopped + +#volumes: +# grafana-storage: # prometheus: # loki: \ No newline at end of file