Compare commits

...

2 Commits
v1.0.0 ... main

Author SHA1 Message Date
fb3aa067ef update README.md 2025-06-09 08:50:16 +02:00
aa8d155d9d v1.1.0 2025-06-09 07:53:44 +02:00
5 changed files with 182 additions and 25 deletions

View File

@ -7,11 +7,13 @@ COMPOSE_PROJECT_NAME=gmo-loki
# certificats path (ex: /home/docker/certs) # certificats path (ex: /home/docker/certs)
PRX_CERTS_DIR=<path_to_your_gtw_data_dir> PRX_CERTS_DIR=<path_to_your_gtw_data_dir>
# nginx default.conf file path (ex: /home/docker/nginx) # 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 # 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> 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 # user
MINIO_ACCESS_KEY=minio MINIO_ACCESS_KEY=minio
# passord # passord
@ -29,3 +31,8 @@ GF_VOLUME_DIR=<path_to_your_gf_data_dir>
# url redirect (ex: https://docker1.gmolab.net/grafana/) # url redirect (ex: https://docker1.gmolab.net/grafana/)
GF_ROOT_URL=<server_fqdn>/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>

102
README.md
View File

@ -9,6 +9,9 @@ This dokcer run stack grafana, loki, promtail, minio
| <COMPOSE_PROJECT_NAME>-proxy-1 | `https://<server_fqdn>` | nginx proxy | <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>-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>-grafana-1 | `https://<server_fqdn>/grafana` | grafana |
| <COMPOSE_PROJECT_NAME>-minio-cli-1 | - | client minio |
| <COMPOSE_PROJECT_NAME>-prometheus-1 | `http://<server_fqdn>:9090` | prometheus |
| <COMPOSE_PROJECT_NAME>-node-exporter-1 | - | node metrics for prometheus |
## Requirements ## Requirements
### Certificats ### Certificats
Create a folder named `/home/docker/certs` and copy your certificates into it. Create a folder named `/home/docker/certs` and copy your certificates into it.
@ -34,22 +37,79 @@ Create the folder where the minio data will be stored
sudo mkdir -p /home/docker/minio 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 ### Grafana
Create the folder where the grafana data will be stored Create the folder where the grafana data will be stored
```bash ```bash
sudo mkdir -p /home/docker/grafana 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 ## Run
```bash ```bash
docker compose up -d 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 ## Access
**dns-tools** **dns-tools**
```bash ```bash
docker exec -it dns-tools /bin/bash docker exec -it <COMPOSE_PROJECT_NAME>-dns-tools /bin/bash
``` ```
```bash ```bash
dig minio-server dig minio-server
@ -57,12 +117,36 @@ ping minio-server
nslookup minio-server nslookup minio-server
``` ```
**Minio console** **minio**
`https://<server_fqdn>/minio/ui/` `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/` `https://<server_fqdn>/grafana/`
**prometheus**
`http://<server_fqdn>:9090`
## Metrics access
**node-exporter**
```bash
docker exec -it <COMPOSE_PROJECT_NAME>-proxy-1 /bin/sh -c "curl http://node-exporter:9100/metrics"
```
**prometheus**
```bash
docker exec -it <COMPOSE_PROJECT_NAME>-proxy-1 /bin/sh -c "curl http://prometheus:9090/metrics"
```
**minio**
```bash
TOKEN=$(echo "Authorization: Bearer $(grep "bearer_token" config/prometheus.yml | cut -d':' -f2 |cut -d' ' -f2)")
```
```bash
docker exec -it gmo-loki-proxy-1 /bin/bash -c "curl -H \"Accept: application/json\" -H \"${TOKEN}\" http://minio:9000/minio/v2/metrics/cluster"
```
## Sources ## Sources
### Minio ### Minio
* https://github.com/Anagraph/minio-docker-config/blob/master/docker-compose.yaml * https://github.com/Anagraph/minio-docker-config/blob/master/docker-compose.yaml
@ -72,7 +156,19 @@ nslookup minio-server
* https://grafana.com/docs/loki/latest/setup/install/docker/ * https://grafana.com/docs/loki/latest/setup/install/docker/
* https://grafana.com/tutorials/run-grafana-behind-a-proxy/ * https://grafana.com/tutorials/run-grafana-behind-a-proxy/
### Prometheus
* https://mxulises.medium.com/simple-prometheus-setup-on-docker-compose-f702d5f98579
## Changelog ## 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 ### [1.0.0] - 2025-06-08
#### Added #### Added
- init docker container - init docker container

View File

@ -57,4 +57,8 @@ server {
proxy_pass http://minio:9001/; 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 name: loki-net # replace the default domain <service>.loki-net
services: services:
# init container to change permissions of the mounted directory. #------- init container to change permissions of the mounted directory.
init: init:
image: busybox image: busybox
user: root user: root
@ -11,15 +11,17 @@ services:
/bin/sh -c " /bin/sh -c "
chown 472:root /var/lib/grafana; chown 472:root /var/lib/grafana;
chown 101:root /etc/nginx/conf.d/default.conf; chown 101:root /etc/nginx/conf.d/default.conf;
chown nobody:nobody /prometheus -R;
exit 0; exit 0;
" "
volumes: volumes:
- '${GF_VOLUME_DIR}:/var/lib/grafana' - '${GF_VOLUME_DIR}:/var/lib/grafana'
- '${PRX_NGINX_CONF_DIR}/default.conf:/etc/nginx/conf.d/default.conf' - '${PRX_NGINX_CONF_DIR}/default.conf:/etc/nginx/conf.d/default.conf'
- '${PROM_DATA_DIR}:/prometheus'
networks: networks:
- loki - 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: # dns-tools:
# image: jonlabelle/network-tools # image: jonlabelle/network-tools
# command: tail -f /dev/null # command: tail -f /dev/null
@ -27,6 +29,8 @@ services:
# tty: true # tty: true
# networks: # networks:
# - loki # - loki
#-------proxy (nginx)
proxy: proxy:
image: nginxinc/nginx-unprivileged image: nginxinc/nginx-unprivileged
volumes: volumes:
@ -37,11 +41,12 @@ services:
#- "80:8080" #- "80:8080"
networks: networks:
- loki - loki
restart: unless-stopped restart: always
#
# minio server service #------- minio server service
minio: minio:
image: minio/minio #image: minio/minio
image: minio/minio:RELEASE.2025-03-12T18-04-18Z
restart: always restart: always
volumes: volumes:
- ${MINIO_DATA_ROOT_DIR}:/data - ${MINIO_DATA_ROOT_DIR}:/data
@ -56,24 +61,30 @@ services:
networks: networks:
- loki - loki
# service not necessary, used here to explain how to interact from the container #------- minio client
# minio-client: # minio-cli:
# image: minio/mc # image: minio/mc
# # insure that the server container is running before building the client # # insure that the server container is running before building the client
# depends_on: # depends_on:
# - minio # - minio
# entrypoint: > # entrypoint: >
# /bin/sh -c " # /bin/sh -c "tail -f /dev/null"
# /usr/bin/mc admin info play; # #/usr/bin/mc admin info play;
# /usr/bin/mc alias set myminio http://minio:9000 ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY}; # #/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 admin prometheus generate myminio
# /usr/bin/mc mb myminio/loki-1; # ##/usr/bin/mc mb myminio/test-bucket;
# echo 'my content' > myfile.txt; # ##/usr/bin/mc mb myminio/loki-1;
# /usr/bin/mc cp myfile.txt myminio/test-bucket; # ##echo 'my content' > myfile.txt;
# exit 0; # ##/usr/bin/mc cp myfile.txt myminio/test-bucket;
# " # #exit 0;
# #"
# volumes:
# - ${MINIO_CONF_CLI_DIR}/.mc:/root/.mc
# restart: unless-stopped
# networks: # networks:
# - loki # - loki
#------- grafana
grafana: grafana:
image: grafana/grafana-enterprise image: grafana/grafana-enterprise
ports: ports:
@ -89,7 +100,28 @@ services:
networks: networks:
- loki - loki
#------- prometheus
prometheus:
image: prom/prometheus
volumes: volumes:
grafana-storage: - ${PROM_CONF_DIR}/prometheus.yml:/etc/prometheus/prometheus.yml
- ${PROM_DATA_DIR}:/prometheus
ports:
- 9090:9090
restart: unless-stopped
networks:
- loki
#------- node-exporter
node-exporter:
image: prom/node-exporter
networks:
- loki
ports:
- 9100:9100
restart: unless-stopped
#volumes:
# grafana-storage:
# prometheus: # prometheus:
# loki: # loki: