This commit is contained in:
Gilles Mouchet 2025-06-09 07:53:44 +02:00
parent 4b6137f6e2
commit aa8d155d9d
5 changed files with 163 additions and 25 deletions

View File

@ -7,11 +7,13 @@ COMPOSE_PROJECT_NAME=gmo-loki
# certificats path (ex: /home/docker/certs)
PRX_CERTS_DIR=<path_to_your_gtw_data_dir>
# nginx default.conf file path (ex: /home/docker/nginx)
PRX_NGINX_CONF_DIR=<path_to_your_gtw_data_dir>
PRX_NGINX_CONF_DIR=<path_to_your_gtw_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_to_your_minio_data_dir>
# path where mino client will be stored (ex: /home/docker/minio-cli)
MINIO_CONF_CLI_DIR=<path_to_your_minio_conf_dir>
# user
MINIO_ACCESS_KEY=minio
# passord
@ -29,3 +31,8 @@ GF_VOLUME_DIR=<path_to_your_gf_data_dir>
# url redirect (ex: https://docker1.gmolab.net/grafana/)
GF_ROOT_URL=<server_fqdn>/grafana/
#------------------------------------------------
# prometheus
# conf dir prometheus.yml
PROM_CONF_DIR=<path_to_your_prom_conf_dir>
# data dir (ex: /home/docker/prometheus-data)
PROM_DATA_DIR=<path_to_your_prom_data_dir>

View File

@ -9,6 +9,7 @@ This dokcer run stack grafana, loki, promtail, minio
| <COMPOSE_PROJECT_NAME>-proxy-1 | `https://<server_fqdn>` | nginx proxy
| <COMPOSE_PROJECT_NAME>-minio-1 | UI: `https://<server_fqdn>/minio/ui`<br>API: `http://127.0.0.1:9000`| container minio server UI and API |
| <COMPOSE_PROJECT_NAME>-grafana-1 | `https://<server_fqdn>/grafana` | grafana |
| <COMPOSE_PROJECT_NAME>-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 <COMPOSE_PROJECT_NAME>-minio-cli-1 /bin/sh -c "mc alias set myminio http://minio:9000 <MINIO_ACCESS_KEY> <MINIO_SECRET_KEY>"
```
Create prometheus metrics job
```bash
docker exec -it <COMPOSE_PROJECT_NAME>-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 <COMPOSE_PROJECT_NAME>-dns-tools /bin/bash
```
```bash
dig minio-server
@ -57,12 +115,19 @@ ping minio-server
nslookup minio-server
```
**Minio console**
**minio**
`https://<server_fqdn>/minio/ui/`
**Grafana**
**minio-cli**
```bash
docker exec -it <COMPOSE_PROJECT_NAME>-minio-cli-1 /bin/sh
```
**grafana**
`https://<server_fqdn>/grafana/`
**prometheus**
`http://<server_fqdn>: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

View File

@ -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/;
# }
}

18
config/prometheus.yml Normal file
View File

@ -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']

View File

@ -3,7 +3,7 @@ networks:
name: loki-net # replace the default domain <service>.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: