Grafana is an open-source analytics and monitoring platform that provides visualization capabilities for time-series data. In our project, we use Grafana exclusively with Prometheus for system and application metrics monitoring. This setup enables us to visualize performance metrics, track usage patterns, and detect anomalies in our application.
For more about Prometheus visit prometheus.md.
Our Grafana instance is configured using a custom Docker image and configuration file. The configuration ensures that Grafana is accessible through a sub-path in our reverse proxy setup.
grafana:
<<: *common
build:
context: ./src/grafana
dockerfile: Dockerfile.grafana
profiles: ["grafanaprofile"]
container_name: grafana
ports:
- "3000:3000"
environment:
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_BASIC_ENABLED=true
- ENABLE_LOGS_GRAFANA=true
- GF_SECURITY_ADMIN_USER=${GF_SECURITY_ADMIN_USER}
- GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD}
- GF_INSTALL_PLUGINS=redis-datasource
- GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=redis-datasource
depends_on:
redis:
condition: service_healthy
logging:
driver: gelf
options:
gelf-address: "udp://${LOG_HOST}:12201"
tag: "grafana"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000 || exit 1"]
interval: 30s
timeout: 10s
retries: 5
We use a custom grafana.ini
file to configure Grafana’s core behavior:
[server]
root_url = http://localhost/grafana/
serve_from_sub_path = true
[log]
mode = file
level = info
file_name = /var/log/grafana/grafana.log
This configuration enables:
In this project, we exclusively use Prometheus as our metrics data source. Prometheus collects and stores time-series metrics from our services, which Grafana visualizes.
We also utilize the Redis data source plugin to monitor Redis performance directly.
Our Grafana implementation includes several pre-configured dashboards for monitoring:
These dashboards are saved persistently in Docker volumes, ensuring they remain available across container restarts.
Grafana is accessible via the /grafana/
path through our reverse proxy at http://localhost:8080/grafana/
.
While the Grafana container exposes port 3000, direct access at http://localhost:3000
is not recommended due to the sub-path configuration in grafana.ini
.
Login credentials are configured via environment variables:
GF_SECURITY_ADMIN_USER
GF_SECURITY_ADMIN_PASSWORD
This configuration is primarily intended for development environments. For production, additional security measures would be recommended, such as: