Skip to content

Commit e3b51d1

Browse files
authored
Update README.md
1 parent bdb5677 commit e3b51d1

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

README.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,55 +58,73 @@ mkdir ~/monitoring && cd ~/monitoring
5858

5959
### Step 3: Create Prometheus config file
6060
Create a file named `prometheus.yml`:
61+
See example from my prometheus folder
6162
```yaml
6263
global:
6364
scrape_interval: 15s
6465
scrape_configs:
65-
- job_name: 'docker'
66+
- job_name: 'flask-app'
6667
static_configs:
67-
- targets: ['localhost:9323']
68+
- targets: ['web-app:5000']
69+
- job_name: 'cadvisor'
70+
static_configs:
71+
- targets: ['cadvisor:9323']
6872
```
69-
70-
### Step 4: Run Prometheus and Grafana in Docker
73+
### Step 4: Create Docker Network
74+
Docker network helps the containers in docker to communicate with each, this docker network is used among all.
75+
Create docker network if not created. It is created in `Github Actions` ci-cd pipeline. Check with this command. `
76+
```bash
77+
docker network create devops-net
78+
```
79+
### Step 5: Run Prometheus and Grafana in Docker
7180
```bash
7281
# Run Prometheus
73-
docker run -d \
82+
docker run -d --name prometheus \
83+
--network devops-net \
7484
-p 9090:9090 \
7585
-v ~/monitoring/prometheus.yml:/etc/prometheus/prometheus.yml \
76-
--name prometheus \
7786
prom/prometheus
7887
7988
# Run Grafana
80-
docker run -d \
89+
docker run -d --name grafana \
90+
--network devops-net \
8191
-p 3000:3000 \
82-
--name=grafana \
8392
grafana/grafana
8493
```
8594

86-
### Step 5: Install Docker Metrics Exporter
95+
### Step 6: (Optional) Install Docker Metrics Exporter
8796
Prometheus needs metrics from Docker – install this exporter:
8897
```bash
89-
docker run -d \
98+
docker run -d --name cadvisor \
99+
--network devops-net \
90100
-p 9323:9323 \
91101
-v /var/run/docker.sock:/var/run/docker.sock \
92-
--name cadvisor \
102+
-v /:/rootfs:ro \
103+
-v /var/run:/var/run:ro \
104+
-v /sys:/sys:ro \
105+
-v /var/lib/docker/:/var/lib/docker:ro \
93106
google/cadvisor:latest
94107
```
95108

96-
### Step 6: Access Grafana on Browser
109+
### Step 7: Access Grafana on Browser
97110
Open: http://<your-azure-vm-ip>:3000
98111

99112
Default login:
100113
- User: admin
101114
- Password: admin (you'll be prompted to change)
102115

103-
### Step 7: Connect Prometheus as Grafana Data Source
116+
Confirm Everything Works
117+
1. http://<vm-ip>:5000/metrics → Should show Flask app metrics
118+
2. http://<vm-ip>:9090/targets → Prometheus should show flask-app:5000 and cadvisor:9323 as UP
119+
3. http://<vm-ip>:3000 → Grafana dashboard
120+
121+
### Step 8: Connect Prometheus as Grafana Data Source
104122
In Grafana:
105123
1. Go to Settings → Data Sources → Add Prometheus
106-
2. URL: http://localhost:9090
124+
2. URL: http://<az-vm-ip>:9090
107125
3. Click Save & Test
108126

109-
### Step 8: Import a Dashboard
127+
### Step 9: Import a Dashboard
110128
1. Go to + → Import
111129
2. Paste Dashboard ID: 193 (Docker metrics)
112130
3. Click Load → Select Prometheus as data source → Import

0 commit comments

Comments
 (0)