Skip to content

k4mien/nginx-monitoring

Repository files navigation

nginx-monitoring

Monitoring stack for nginx ssl web server

Table of contents

Demo

Screenshot 2024-07-09 005607 Screenshot 2024-07-09 005620

Tech stack

  • Docker
  • Nginx
  • Grafana
  • Prometheus
  • Node-Exporter
  • Cadvisor
  • Nginx-Prom-Exporter

Features

  • pre-configured, only cert/key and dhparam are needed to generate
  • clean dashboard
  • selfsigned ssl for web server
  • useful metrics

To do

  • more complex metrics

Installation

  1. Git clone this repo
git clone https://github.com/k4mien/nginx-monitoring.git
  1. Change directory to project
cd nginx-monitoring
  1. 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
  1. Start docker compose
docker compose up -d

More

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published