From 80259e6afd24417c6e365da2450c9c03e2acf117 Mon Sep 17 00:00:00 2001 From: coolneng Date: Tue, 18 Apr 2023 21:18:38 +0200 Subject: [PATCH] Monitor nginx via Prometheus --- modules/monitoring.nix | 8 +++++++- modules/webstack.nix | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/monitoring.nix b/modules/monitoring.nix index ded0e42..2755cc8 100644 --- a/modules/monitoring.nix +++ b/modules/monitoring.nix @@ -56,8 +56,11 @@ with pkgs; wireguard.enable = true; postgres.enable = true; smartctl.enable = true; - #nginx.enable = true; dnsmasq.enable = true; + nginx = { + enable = true; + scrapeUri = "http://localhost:8282/nginx_status"; + }; }; scrapeConfigs = [{ job_name = "zion"; @@ -77,6 +80,9 @@ with pkgs; "localhost:${ toString config.services.prometheus.exporters.dnsmasq.port }" + "localhost:${ + toString config.services.prometheus.exporters.nginx.port + }" "localhost:9641" ]; }]; diff --git a/modules/webstack.nix b/modules/webstack.nix index 4db9df5..9e9e835 100644 --- a/modules/webstack.nix +++ b/modules/webstack.nix @@ -49,12 +49,6 @@ add_header Access-Control-Allow-Origin * always; ''; }; - "/nginx_status/".extraConfig = '' - stub_status on; - access_log off; - allow 127.0.0.1; - deny all; - ''; }; }; "radicale.coolneng.duckdns.org" = { @@ -164,6 +158,18 @@ proxyWebsockets = true; }; }; + "/nginx_status/" = { + listen = [{ + addr = "127.0.0.1"; + port = 8282; + }]; + extraConfig = '' + stub_status on; + access_log off; + allow 127.0.0.1; + deny all; + ''; + }; }; };