For this example we will use Docker compose to be able to run all the services
- Docker Compose
version: "3.9"
services:
grafana:
image: grafana/grafana
ports:
- 3000:3000
prometheus:
image: prom/prometheus
container_name: prometheus
ports:
- 9090:9090
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
redis:
image: "bitnami/redis:latest"
ports:
- 6379:6379
environment:
- REDIS_REPLICATION_MODE=master
- REDIS_PASSWORD=my_master_password
redis-exporter:
image: oliver006/redis_exporter
ports:
- 9121:9121
restart: unless-stopped
environment:
REDIS_ADDR: "redis:6379"
REDIS_USER: null
REDIS_PASSWORD: my_master_password
links:
- redis
- prometheus
2.Prometheus File Settings (prometheus.yml)
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
- job_name: redis-exporter
static_configs:
- targets: ['redis-exporter:9121']
3.Run Docker Compose
docker-compose up
4.Check status of Prometheus and Redis Exporter
http://localhost:9090/targets
5.Visit Grafana Dashboard
Default
User: admin
Password: admin
http://localhost:3000
6.Add data source
Save and test
7.Import Redis Dashboard for Prometheus
For this we will use a Dashboard created by the community
https://grafana.com/grafana/dashboards/763
8.Import JSON or code
Code: 763
JSON:
https://grafana.com/api/dashboards/763/revisions/3/download
9.Dashboard
Code of example (GitHub Gist)
https://gist.github.com/nelsoncode019/722727fdba11d846e39dc99f8064f7fe
Top comments (5)
Step 6 I get:
Error reading Prometheus: Post "localhost:9090/api/v1/query": dial tcp 127.0.0.1:9090: connect: connection refused
you must write prometheus:9090
to access the Internal Docker network
Ah I missed that, thanks a lot!
Very useful. Just did a POC based on this blog post.
Now, I need to pitch to my cloud engineer lead to implement it.
Found a mistake in docker-compose.yaml. It should be redis_exporter: