Skip to content

Commit e745269

Browse files
committed
Fix pre-commit issues: trailing whitespace, line length, YAML, and TOC updates
1 parent 54ebea9 commit e745269

File tree

7 files changed

+110
-42
lines changed

7 files changed

+110
-42
lines changed

.github/workflows/test-docker-compose-ci.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Wait for services to be ready
5454
run: |
5555
echo "Waiting for services to be ready..."
56-
56+
5757
# Wait for NGINX to be ready
5858
for i in {1..30}; do
5959
if curl -s http://localhost:8081/stub_status > /dev/null 2>&1; then
@@ -63,7 +63,7 @@ jobs:
6363
echo "Waiting for NGINX stub_status... (attempt $i/30)"
6464
sleep 2
6565
done
66-
66+
6767
# Wait for NGINX Exporter to be ready
6868
for i in {1..30}; do
6969
if curl -s http://localhost:9113/metrics > /dev/null 2>&1; then
@@ -78,15 +78,15 @@ jobs:
7878
run: |
7979
echo "Verifying container status..."
8080
docker-compose ps
81-
81+
8282
# Check if nginx-exporter container is running
8383
if ! docker-compose ps nginx-exporter | grep -q "Up"; then
8484
echo "❌ NGINX Exporter container is not running"
8585
docker-compose logs nginx-exporter
8686
exit 1
8787
fi
8888
echo "✓ NGINX Exporter container is running"
89-
89+
9090
# Check if nginx container is running
9191
if ! docker-compose ps nginx | grep -q "Up"; then
9292
echo "❌ NGINX container is not running"
@@ -99,12 +99,12 @@ jobs:
9999
run: |
100100
echo "Testing NGINX stub_status endpoint..."
101101
response=$(curl -s http://localhost:8081/stub_status)
102-
102+
103103
if [[ -z "$response" ]]; then
104104
echo "❌ NGINX stub_status endpoint returned empty response"
105105
exit 1
106106
fi
107-
107+
108108
# Check if response contains expected metrics
109109
if echo "$response" | grep -q "Active connections:"; then
110110
echo "✓ NGINX stub_status endpoint is working correctly"
@@ -118,12 +118,12 @@ jobs:
118118
run: |
119119
echo "Testing NGINX Exporter metrics endpoint..."
120120
response=$(curl -s http://localhost:9113/metrics)
121-
121+
122122
if [[ -z "$response" ]]; then
123123
echo "❌ NGINX Exporter metrics endpoint returned empty response"
124124
exit 1
125125
fi
126-
126+
127127
# Check if response contains expected NGINX metrics
128128
if echo "$response" | grep -q "nginx_connections_accepted"; then
129129
echo "✓ NGINX Exporter metrics endpoint is working correctly"
@@ -136,20 +136,20 @@ jobs:
136136
- name: Verify metrics collection
137137
run: |
138138
echo "Verifying metrics collection..."
139-
139+
140140
# Generate some traffic to NGINX
141141
echo "Generating traffic to NGINX..."
142142
for i in {1..5}; do
143143
curl -s http://localhost:80 > /dev/null || true
144144
sleep 1
145145
done
146-
146+
147147
# Wait a moment for metrics to be updated
148148
sleep 3
149-
149+
150150
# Check if metrics are being collected
151151
metrics=$(curl -s http://localhost:9113/metrics)
152-
152+
153153
# Verify nginx_up metric exists and is 1
154154
if echo "$metrics" | grep -q "nginx_up 1"; then
155155
echo "✓ NGINX Exporter is successfully collecting metrics"
@@ -159,7 +159,7 @@ jobs:
159159
echo "$metrics" | grep "nginx_up" || echo "nginx_up metric not found"
160160
exit 1
161161
fi
162-
162+
163163
# Verify connection metrics exist
164164
if echo "$metrics" | grep -q "nginx_connections_accepted"; then
165165
echo "✓ Connection metrics are being collected"
@@ -171,7 +171,7 @@ jobs:
171171
- name: Test service connectivity
172172
run: |
173173
echo "Testing service connectivity..."
174-
174+
175175
# Test that services can communicate internally
176176
docker exec nginx-prometheus-exporter curl -f http://nginx:8081/stub_status > /dev/null
177177
echo "✓ Services can communicate internally"
@@ -214,13 +214,13 @@ jobs:
214214
- name: Wait for all services to be ready
215215
run: |
216216
echo "Waiting for all services to be ready..."
217-
217+
218218
# Wait for all services to be healthy
219219
services=("nginx:8081/stub_status" "nginx-exporter:9113/metrics" "prometheus:9090/-/ready" "grafana:3000/api/health")
220-
220+
221221
for service in "${services[@]}"; do
222222
IFS=':' read -r host_port path <<< "$service"
223-
223+
224224
for i in {1..60}; do
225225
if curl -s "http://localhost:${host_port}${path}" > /dev/null 2>&1; then
226226
echo "✓ Service ${host_port} is ready"
@@ -235,10 +235,10 @@ jobs:
235235
run: |
236236
echo "Verifying all containers are running..."
237237
docker-compose ps
238-
238+
239239
# Check that all expected services are up
240240
services=("nginx" "nginx-exporter" "prometheus" "grafana" "app")
241-
241+
242242
for service in "${services[@]}"; do
243243
if ! docker-compose ps "$service" | grep -q "Up"; then
244244
echo "❌ Service $service is not running"
@@ -251,7 +251,7 @@ jobs:
251251
- name: Test full stack integration
252252
run: |
253253
echo "Testing full stack integration..."
254-
254+
255255
# Test Prometheus can scrape NGINX Exporter
256256
prometheus_targets=$(curl -s http://localhost:9090/api/v1/targets)
257257
if echo "$prometheus_targets" | grep -q "nginx-exporter:9113"; then
@@ -260,7 +260,7 @@ jobs:
260260
echo "❌ Prometheus is not configured to scrape NGINX Exporter"
261261
exit 1
262262
fi
263-
263+
264264
# Test Grafana is accessible
265265
grafana_health=$(curl -s http://localhost:3000/api/health)
266266
if echo "$grafana_health" | grep -q "ok"; then

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ NGINX Prometheus exporter makes it possible to monitor NGINX or NGINX Plus using
2727
- [Prerequisites](#prerequisites)
2828
- [Running the Exporter in a Docker Container](#running-the-exporter-in-a-docker-container)
2929
- [Running the Exporter Binary](#running-the-exporter-binary)
30+
- [Docker Compose Setup](#docker-compose-setup)
3031
- [Usage](#usage)
3132
- [Command-line Arguments](#command-line-arguments)
3233
- [Exported Metrics](#exported-metrics)
@@ -157,21 +158,25 @@ in a Docker container.
157158

158159
### Docker Compose Setup
159160

160-
For a complete monitoring stack including NGINX, NGINX Prometheus Exporter, Prometheus, and Grafana, see the [Docker Compose example](./examples/docker-compose/README.md).
161+
For a complete monitoring stack including NGINX, NGINX Prometheus Exporter, Prometheus, and Grafana,
162+
see the [Docker Compose example](./examples/docker-compose/README.md).
161163

162164
The Docker Compose setup provides:
165+
163166
- NGINX server with stub_status enabled
164167
- NGINX Prometheus Exporter for metrics collection
165168
- Prometheus for time-series storage
166169
- Grafana for visualization with pre-configured dashboards
167170
- Sample web application for testing
168171

169172
Quick start (nginx-exporter only):
173+
170174
```console
171175
docker-compose up -d nginx-exporter
172176
```
173177

174178
For a complete monitoring stack with all services:
179+
175180
```console
176181
docker-compose up -d
177182
```

docker-compose.test.yml

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
version: '3.8'
2-
31
services:
42
# Sample web application
53
app:
64
image: nginx:alpine
75
container_name: sample-app
86
volumes:
9-
- ./docker/app/nginx.conf:/etc/nginx/nginx.conf
10-
- ./docker/app/html:/usr/share/nginx/html
7+
- ./examples/docker-compose/app/nginx.conf:/etc/nginx/nginx.conf
8+
- ./examples/docker-compose/app/html:/usr/share/nginx/html
119
ports:
1210
- "8080:80"
1311
networks:
@@ -21,8 +19,8 @@ services:
2119
depends_on:
2220
- app
2321
volumes:
24-
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
25-
- ./docker/nginx/conf.d:/etc/nginx/conf.d
22+
- ./examples/docker-compose/nginx/nginx.conf:/etc/nginx/nginx.conf
23+
- ./examples/docker-compose/nginx/conf.d:/etc/nginx/conf.d
2624
ports:
2725
- "80:80"
2826
- "8081:8081" # stub_status port
@@ -45,6 +43,51 @@ services:
4543
- nginx-monitoring
4644
restart: unless-stopped
4745

46+
# Prometheus
47+
prometheus:
48+
image: prom/prometheus:latest
49+
container_name: prometheus
50+
depends_on:
51+
- nginx-exporter
52+
volumes:
53+
- ./examples/docker-compose/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
54+
- prometheus_data:/prometheus
55+
ports:
56+
- "9090:9090"
57+
networks:
58+
- nginx-monitoring
59+
restart: unless-stopped
60+
command:
61+
- --config.file=/etc/prometheus/prometheus.yml
62+
- --storage.tsdb.path=/prometheus
63+
- --web.console.libraries=/etc/prometheus/console_libraries
64+
- --web.console.templates=/etc/prometheus/consoles
65+
- --storage.tsdb.retention.time=200h
66+
- --web.enable-lifecycle
67+
68+
# Grafana
69+
grafana:
70+
image: grafana/grafana:latest
71+
container_name: grafana
72+
depends_on:
73+
- prometheus
74+
volumes:
75+
- grafana_data:/var/lib/grafana
76+
- ./examples/docker-compose/grafana/provisioning:/etc/grafana/provisioning
77+
- ./examples/docker-compose/grafana/dashboards:/var/lib/grafana/dashboards
78+
ports:
79+
- "3000:3000"
80+
networks:
81+
- nginx-monitoring
82+
restart: unless-stopped
83+
environment:
84+
- GF_SECURITY_ADMIN_PASSWORD=admin123
85+
- GF_USERS_ALLOW_SIGN_UP=false
86+
87+
volumes:
88+
prometheus_data:
89+
grafana_data:
90+
4891
networks:
4992
nginx-monitoring:
5093
driver: bridge

0 commit comments

Comments
 (0)