grafana-loki-minio/README.md
2025-06-13 17:07:45 +02:00

210 lines
5.2 KiB
Markdown

# Grafana-Loki-Minio
## Description
This dokcer run stack grafana, loki, promtail, minio
### Container
| Name | URL | Description |
|:---|:---|:---|
| <COMPOSE_PROJECT_NAME>-dns-tools-1 | - | container with dns tools (just use for debug)|
| <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 |
| <COMPOSE_PROJECT_NAME>-prometheus-1 | `http://<server_fqdn>:9090` | prometheus |
| <COMPOSE_PROJECT_NAME>-node-exporter-1 | - | node metrics for prometheus |
## Requirements
### Certificats
Create a folder named `/home/docker/certs` and copy your certificates into it.
```bash
sudo mkdir -p /home/docker/certs
```
### Variables
All variables are described in the `.env.dist` file
Copy the `.env.dist` file to `.env` and update it with values appropriate for your setup.
### Proxy (nginx)
Create the folder where the ngnix config will be stored and copy the `config/nginx.conf` into it
```bash
sudo mkdir -p /home/docker/nginx
sudo cp ./config/default.conf /home/docker/nginx/.
```
### Minio
Create the folder where the minio data will be stored
```bash
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
```
### Loki
Create the folder where the loki config will be stored
```bash
sudo mkdir -p /home/docker/loki
```
Create the folder where the loki data will be stored
```bash
sudo mkdir -p /home/docker/loki-data
```
Create the folder where the loki log generated will be stored
```bash
sudo mkdir -p /home/docker/loki-gen-log
```
### Promtail
Create the folder where the promtail config will be stored
```bash
sudo mkdir -p /home/docker/promtail
```
## 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 <COMPOSE_PROJECT_NAME>-dns-tools /bin/bash
```
```bash
dig minio-server
ping minio-server
nslookup minio-server
```
**minio**
`https://<server_fqdn>/minio/ui/`
**minio-cli**
```bash
docker exec -it <COMPOSE_PROJECT_NAME>-minio-cli-1 /bin/sh
```
**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
### Minio
* https://github.com/Anagraph/minio-docker-config/blob/master/docker-compose.yaml
* https://min.io/docs/minio/linux/integrations/setup-nginx-proxy-with-minio.html
### Grafana
* 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
### Loki/promtail
* https://blog.stephane-robert.info/docs/observer/logs/loki/
* https://grafana.com/docs/loki/latest/setup/install/docker/
* https://medium.com/@netopschic/implementing-the-log-monitoring-stack-using-promtail-loki-and-grafana-using-docker-compose-bcb07d1a51aa
## 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
- 13639 Loki - Log analysis
### [1.0.0] - 2025-06-08
#### Added
- init docker container
- proxy with nginx
- minio container
- grafana container
#### Project initialization
- initialization by [GMo](mailto:gilles.mouchet@gmail.com)