Skip to content

Commit 3d7ff39

Browse files
committed
Add Docker Compose documentation
- Add comprehensive Docker Compose documentation in examples/docker-compose/README.md - Include architecture overview, quick start guide, and service descriptions - Add testing instructions and troubleshooting section - Update main README.md to reference Docker Compose example - Focus quick start on nginx-exporter only for existing NGINX setups - Provide separate instructions for complete monitoring stack - Add configuration file references and usage examples
1 parent 81466ae commit 3d7ff39

File tree

2 files changed

+169
-0
lines changed

2 files changed

+169
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,27 @@ To start the exporter we use the [docker run](https://docs.docker.com/engine/ref
155155
follow the example in [examples/systemd](./examples/systemd/README.md). Alternatively, you can run the exporter
156156
in a Docker container.
157157

158+
### Docker Compose Setup
159+
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+
162+
The Docker Compose setup provides:
163+
- NGINX server with stub_status enabled
164+
- NGINX Prometheus Exporter for metrics collection
165+
- Prometheus for time-series storage
166+
- Grafana for visualization with pre-configured dashboards
167+
- Sample web application for testing
168+
169+
Quick start (nginx-exporter only):
170+
```console
171+
docker-compose up -d nginx-exporter
172+
```
173+
174+
For a complete monitoring stack with all services:
175+
```console
176+
docker-compose up -d
177+
```
178+
158179
## Usage
159180

160181
### Command-line Arguments

examples/docker-compose/README.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Docker Compose Setup for NGINX Prometheus Exporter
2+
3+
This Docker Compose configuration provides a complete monitoring stack for NGINX using Prometheus and Grafana.
4+
5+
## Table of Contents
6+
7+
- [Architecture](#architecture)
8+
- [Quick Start](#quick-start)
9+
- [Services](#services)
10+
- [nginx-exporter](#nginx-exporter)
11+
- [nginx (Main Server)](#nginx-main-server)
12+
- [app (Sample Application)](#app-sample-application)
13+
- [prometheus](#prometheus)
14+
- [grafana](#grafana)
15+
- [Configuration Files](#configuration-files)
16+
- [Testing](#testing)
17+
- [Stopping](#stopping)
18+
- [Troubleshooting](#troubleshooting)
19+
- [Network](#network)
20+
- [Volumes](#volumes)
21+
22+
## Architecture
23+
24+
The setup includes:
25+
- **nginx**: Main NGINX server with stub_status enabled (for demo purposes)
26+
- **app**: Sample web application served by NGINX (for demo purposes)
27+
- **nginx-exporter**: NGINX Prometheus Exporter that scrapes metrics from NGINX
28+
- **prometheus**: Prometheus time-series database for metrics collection
29+
- **grafana**: Grafana dashboard for visualization
30+
31+
**Note**: If you have an existing NGINX setup, you only need to run the `nginx-exporter` service. Make sure your NGINX has stub_status enabled and is accessible at the configured scrape URI.
32+
33+
## Quick Start
34+
35+
1. **Navigate to the project root directory**:
36+
```bash
37+
cd /path/to/nginx-prometheus-exporter
38+
```
39+
40+
2. **For existing NGINX setup - Start only the nginx-exporter**:
41+
```bash
42+
docker-compose up -d nginx-exporter
43+
```
44+
This assumes you already have NGINX running with stub_status enabled at `http://nginx:8081/stub_status`.
45+
46+
3. **For complete demo setup - Start the full monitoring stack**:
47+
```bash
48+
docker-compose up -d
49+
```
50+
This starts all services including a sample NGINX server, Prometheus, and Grafana.
51+
52+
4. **Access the services**:
53+
- **Sample App**: http://localhost:8080
54+
- **NGINX Server**: http://localhost:80
55+
- **NGINX Metrics**: http://localhost:9113/metrics
56+
- **NGINX Stub Status**: http://localhost:8081/stub_status
57+
- **Prometheus**: http://localhost:9090
58+
- **Grafana**: http://localhost:3000 (admin/admin123)
59+
60+
## Services
61+
62+
### nginx-exporter
63+
- **Image**: `nginx/nginx-prometheus-exporter:latest`
64+
- **Port**: 9113
65+
- **Function**: Scrapes NGINX stub_status and converts to Prometheus metrics
66+
67+
### nginx (Main Server)
68+
- **Image**: `nginx:alpine`
69+
- **Ports**: 80, 8081 (stub_status)
70+
- **Function**: Proxies to sample app and provides metrics endpoint
71+
72+
### app (Sample Application)
73+
- **Image**: `nginx:alpine`
74+
- **Port**: 8080
75+
- **Function**: Serves sample web content
76+
77+
### prometheus
78+
- **Image**: `prom/prometheus:latest`
79+
- **Port**: 9090
80+
- **Function**: Collects and stores metrics from nginx-exporter
81+
82+
### grafana
83+
- **Image**: `grafana/grafana:latest`
84+
- **Port**: 3000
85+
- **Function**: Provides visualization dashboards
86+
87+
## Configuration Files
88+
89+
- `nginx/nginx.conf`: Main NGINX configuration with stub_status
90+
- `app/nginx.conf`: Sample application NGINX configuration
91+
- `prometheus/prometheus.yml`: Prometheus scraping configuration
92+
- `grafana/provisioning/`: Grafana datasource and dashboard configuration
93+
94+
## Testing
95+
96+
1. **Check nginx-exporter metrics**:
97+
```bash
98+
curl http://localhost:9113/metrics | grep nginx
99+
```
100+
101+
2. **Check stub_status directly**:
102+
```bash
103+
curl http://localhost:8081/stub_status
104+
```
105+
106+
3. **Generate traffic**:
107+
```bash
108+
for i in {1..10}; do curl -s http://localhost:80 > /dev/null; done
109+
```
110+
111+
## Stopping
112+
113+
Stop all services:
114+
```bash
115+
docker-compose down
116+
```
117+
118+
Stop and remove volumes:
119+
```bash
120+
docker-compose down -v
121+
```
122+
123+
## Troubleshooting
124+
125+
1. **Check container logs**:
126+
```bash
127+
docker-compose logs nginx-exporter
128+
docker-compose logs nginx
129+
```
130+
131+
2. **Verify container status**:
132+
```bash
133+
docker-compose ps
134+
```
135+
136+
3. **Test internal connectivity**:
137+
```bash
138+
docker exec nginx-server curl -s http://localhost:8081/stub_status
139+
```
140+
141+
## Network
142+
143+
All services run on the `nginx-monitoring` bridge network for internal communication.
144+
145+
## Volumes
146+
147+
- `prometheus_data`: Persistent storage for Prometheus metrics
148+
- `grafana_data`: Persistent storage for Grafana configurations and dashboards

0 commit comments

Comments
 (0)