From 24028669f4c35555a2fcba6c46caf9036f023f62 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 13 Jul 2021 19:10:17 +0200 Subject: [PATCH] modules: services: add monitoring dashboard --- modules/services/nginx.nix | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/services/nginx.nix b/modules/services/nginx.nix index ab90760..b5d49c1 100644 --- a/modules/services/nginx.nix +++ b/modules/services/nginx.nix @@ -1,7 +1,7 @@ # Configuration shamelessly stolen from [1] # # [1]: https://github.com/delroth/infra.delroth.net/blob/master/common/nginx.nix -{ config, pkgs, lib, ... }: +{ config, lib, pkgs, ... }: { # Whenever something defines an nginx vhost, ensure that nginx defaults are @@ -40,5 +40,34 @@ }; }; }; + # Setup monitoring + services.grafana.provision.dashboards = [ + { + name = "NGINX"; + options.path = pkgs.nur.repos.alarsyo.grafana-dashboards.nginx; + disableDeletion = true; + } + ]; + + services.prometheus = { + exporters.nginx = { + enable = true; + listenAddress = "127.0.0.1"; + }; + + scrapeConfigs = [ + { + job_name = "nginx"; + static_configs = [ + { + targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.nginx.port}" ]; + labels = { + instance = config.networking.hostName; + }; + } + ]; + } + ]; + }; }; }