201 lines
5.1 KiB
Markdown
201 lines
5.1 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 |
|
|
| <COMPOSE_PROJECT_NAME>-promtail-1 | - | promtail |
|
|
| <COMPOSE_PROJECT_NAME>-loki-1 | - | loki |
|
|
| <COMPOSE_PROJECT_NAME>-log-generator-1 | - | fake log generator |
|
|
## Requirements
|
|
### Certificats
|
|
Create a folder named `/home/docker/certs` and copy your certificates into it.
|
|
IMPORTANT: Certificates must be named `tls.crt` and `tls.key`
|
|
|
|
```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.
|
|
|
|
## Run
|
|
|
|
Create folder for persistents volumes and copy config files
|
|
To be executed each time the configuration files are modified
|
|
```bash
|
|
./manage.sh config
|
|
```
|
|
|
|
Create container
|
|
```bash
|
|
./manage.sh create
|
|
```
|
|
|
|
Start the stack
|
|
```bash
|
|
./manage.sh start
|
|
```
|
|
|
|
For more information about `manage.sh` script execute `./manage.sh --help`
|
|
|
|
## Config
|
|
### Prometheus
|
|
#### grafana source
|
|
`http://prometheus:9090`
|
|
#### grafana dashboard
|
|
3662 - Prometheus 2.0 Overview
|
|
|
|
### 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 `<PROM_CONF_DIR>/prometheus.yml
|
|
```yaml
|
|
- 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
|
|
```
|
|
#### grafana dashboard
|
|
13502 - MinIO Dashboard
|
|
|
|
### Loki
|
|
Create bulk loki
|
|
```bash
|
|
docker exec -it <COMPOSE_PROJECT_NAME>-minio-cli-1 /bin/sh -c "mc mb myminio/loki"
|
|
```
|
|
#### grafana source
|
|
`http://loki:3100`
|
|
#### grafana dashboard
|
|
13639 - Logs / App
|
|
|
|
### Node exporter
|
|
#### grafana dashboard
|
|
1860 - Node Exporter Full
|
|
|
|
## Fake log generator
|
|
Use for testing only
|
|
```bash
|
|
docker compose up log-generator -d
|
|
```
|
|
On grafana select - Explore - Loki (to the right of Outline) - Label filters job=generated-logs
|
|
```bash
|
|
docker compose stop log-generator
|
|
```
|
|
|
|
## 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 <COMPOSE_PROJECT_NAME>-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.2.0] - 2025-06-14
|
|
#### Added
|
|
- promtail container
|
|
- loki container
|
|
- log generator container
|
|
#### Created
|
|
- script manage.sh
|
|
#### Fixed
|
|
- certificates names
|
|
|
|
### [1.1.0] - 2025-06-09
|
|
#### Added
|
|
- prometheus container
|
|
- node exporter container
|
|
- grafana dashboard
|
|
- 1860 - Node Exporter Full
|
|
- 19268 - Prometheus All Metrics
|
|
- 13502 - MinIO Dashboard
|
|
- 13639 Logs / APP
|
|
|
|
### [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)
|
|
|
|
|