Remove all hardcoded passwords from the example

Robert Drake 2025-10-06 11:45:35 -04:00
parent 2ea6c9a781
commit 9687331902

@ -32,10 +32,11 @@ services:
image: wrouesnel/postgres_exporter:v0.8.0 image: wrouesnel/postgres_exporter:v0.8.0
depends_on: depends_on:
- postgres - postgres
env_file: env/postgres.env
environment: environment:
DATA_SOURCE_URI: postgres?sslmode=disable DATA_SOURCE_URI: postgres?sslmode=disable
DATA_SOURCE_USER: netbox DATA_SOURCE_USER: $${POSTGRES_USER}
DATA_SOURCE_PASS: J5brHrAXFLQSif0K DATA_SOURCE_PASS: $${POSTGRES_PASSWORD}
PG_EXPORTER_AUTO_DISCOVER_DATABASES: 'true' PG_EXPORTER_AUTO_DISCOVER_DATABASES: 'true'
# redis # redis
@ -43,16 +44,16 @@ services:
image: oliver006/redis_exporter image: oliver006/redis_exporter
depends_on: depends_on:
- redis - redis
env_file: env/redis.env
environment: environment:
REDIS_ADDR: redis://redis:6379 REDIS_ADDR: redis://redis:6379
REDIS_PASSWORD: H733Kdjndks81
redis-cache-exporter: redis-cache-exporter:
image: oliver006/redis_exporter image: oliver006/redis_exporter
depends_on: depends_on:
- redis-cache - redis-cache
env_file: env/redis-cache.env
environment: environment:
REDIS_ADDR: redis://redis-cache:6379 REDIS_ADDR: redis://redis-cache:6379
REDIS_PASSWORD: t4Ph722qJ5QHeQ1qfu36
# prometheus # prometheus
prometheus: prometheus:
@ -73,10 +74,9 @@ services:
image: grafana/grafana:latest image: grafana/grafana:latest
depends_on: depends_on:
- prometheus - prometheus
env_file: env/grafana.env
environment: environment:
GF_SECURITY_ADMIN_USER: admin GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: admin
GF_SECURITY_SECRET_KEY: oew5RCBGGBba0MdsEKrj
GF_METRICS_ENABLED: 'true' GF_METRICS_ENABLED: 'true'
ports: ports:
- '3000:3000' - '3000:3000'
@ -120,7 +120,12 @@ scrape_configs:
- targets: ['grafana:3000'] - targets: ['grafana:3000']
``` ```
Then run `docker-compose up`. Finally, create env/grafana.env. You will need to know the ADMIN PASSWORD to login to grafana, but it will be changed on first login.
echo "GF_SECURITY_SECRET_KEY=$(openssl rand -base64 32)" > env/grafana.env
echo "GF_SECURITY_ADMIN_PASSWORD=$(openssl rand -hex 5)" | tee -a env/grafana.env
Then run `docker compose up`.
## Prometheus ## Prometheus
@ -132,7 +137,7 @@ You can access [Prometheus on port 9090](http://localhost:9090).
Grafana provides visualization of the data, which can be composed into dashboard. Grafana provides visualization of the data, which can be composed into dashboard.
To fetch the data it talks directly to the Prometheus service. To fetch the data it talks directly to the Prometheus service.
You can access [Grafana on port 3000](http://localhost:3000). You can access [Grafana on port 3000](http://localhost:3000).
The default credentials are `admin:admin`. The default credentials are `admin` and what was configured in the GF_SECURITY_ADMIN_PASSWORD environment variable in env/grafana.env.
You will find several user-made [dashboards on the Grafana page](https://grafana.com/grafana/dashboards?dataSource=prometheus) which are easy to import using the Grafana Dashboard ID. You will find several user-made [dashboards on the Grafana page](https://grafana.com/grafana/dashboards?dataSource=prometheus) which are easy to import using the Grafana Dashboard ID.
There are already dashboard for Nginx, PostgreSQL, Redis, Prometheus and also Django (which is the framework on which NetBox is built). There are already dashboard for Nginx, PostgreSQL, Redis, Prometheus and also Django (which is the framework on which NetBox is built).