Monitoring stack for nginx ssl web server
- Docker
- Nginx
- Grafana
- Prometheus
- Node-Exporter
- Cadvisor
- Nginx-Prom-Exporter
- pre-configured, only cert/key and dhparam are needed to generate
- clean dashboard
- selfsigned ssl for web server
- useful metrics
- more complex metrics
- Git clone this repo
git clone https://github.com/k4mien/nginx-monitoring.git
- Change directory to project
cd nginx-monitoring
- Generate cert/key and dhparam
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./selfsigned.key -out ./selfsigned.crt -subj "/CN=localhost"
sudo openssl dhparam -out ./dhparam.pem 2048
- Start docker compose
docker compose up -d
By default I kept node-exporter in docker bridge network. It should be running on network_mode=host
or host.
To get network metrics from host you have to change following config:
node_exporter:
image: prom/node-exporter
container_name: node-exporter
command:
- "--path.rootfs=/host"
pid: host
network_mode: host
volumes:
- "/:/host:ro"
Now your node-exporter wont be in docker compose network but host. Then in prometheus.yml
point to host ip rather than docker dns.
global:
scrape_interval: 15s
scrape_configs:
- job_name: nginx-prom
static_configs:
- targets:
- nginx-prom-export:9113
- job_name: node-exporter
static_configs:
- targets:
- <host-ip>:9100
- job_name: cadvisor
static_configs:
- targets:
- cadvisor:8080