Wednesday, 16 February 2022

Monitoring Nginx dengan Grafana Dashboard

sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring
 

 curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor     | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
 

gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg

 

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/debian `lsb_release -cs` nginx"     | sudo tee /etc/apt/sources.list.d/nginx.list
 

echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
    | sudo tee /etc/apt/preferences.d/99nginx

 

sudo apt update && sudo apt upgrade

 

mkdir software

 

sudo apt-get source nginx 

sudo apt-get build-dep nginx

cd nginx/

sudo dpkg -i  lib*.deb

sudo dpkg -i nginx-core_1.18.0-6.1_amd64.deb nginx-common_1.18.0-6.1_all.deb nginx_1.18.0-6.1_all.deb

 

git clone https://github.com/vozlt/nginx-module-vts.git

 

cd /usr/local/src/nginx-1.18.0/

sudo ./configure --with-compat --add-dynamic-module=/home/cendikia/software/nginx-module-vts/

sudo make modules

 

sudo cp objs/ngx_http_vhost_traffic_status_module.so /etc/nginx/modules/
 

Untuk prometheus, kita tidak perlu menggunakan export, karena nginx-module-vts sudah mendukung format untuk prometheus, yg dapat diakses pada alamat :
http://localhost/status/format/prometheus

Konfigurasi prometheus


 /etc/prometheus/prometheus.yml 

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s
    scrape_timeout: 5s

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ['localhost:9090']

  - job_name: node
    # If prometheus-node-exporter is installed, grab stats about the local
    # machine by default.
    static_configs:
      - targets: ['localhost:9100']

  - job_name: 'nginx-vts'
    metrics_path: '/status/format/prometheus'
    static_configs:
      - targets: ['localhost']

Grafana

Untuk Grafana kita menggunakan Dashboard berikut : 

https://grafana.com/grafana/dashboards/14824

 

Referensi

  1. Monitoring Nginx dengan Prometheus dan Grafana, https://nothinux.id/monitoring-nginx-dengan-prometheus-dan-grafana/
  2. Nginx Virtual Host Traffic Status Module to Monitor Nginx,  https://serverdiary.com/web-server/nginx-virtual-host-traffic-status-module-to-monitor-nginx/

1 comment:

  1. For that purpose, we ask that you don't send confidential data corresponding to Social Security, credit card, or account numbers to us by way of an unsecured e mail. The Problem Gambling Network of Ohio strives to generate awareness, promote training, and be an advocate for quality remedy of downside gamblers in the state of Ohio. 온라인 카지노 There isn't any sector-specific EU laws in the subject of gambling services.

    ReplyDelete