diff options
author | Azat Bahawi <azat@bahawi.net> | 2022-08-21 19:13:09 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2022-08-21 19:13:09 +0300 |
commit | 603f14bd7c9e19f25b192c833c45f73c2bb9ccaa (patch) | |
tree | da410c3177c6049cbcac0f73a8ec1c40a5f9e5e3 /modules/nixfiles/monitoring/default.nix | |
parent | e7941cee341350e2b59b33abef99dfc1c36c2ea9 (diff) |
2022-08-21
Diffstat (limited to 'modules/nixfiles/monitoring/default.nix')
-rw-r--r-- | modules/nixfiles/monitoring/default.nix | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/modules/nixfiles/monitoring/default.nix b/modules/nixfiles/monitoring/default.nix new file mode 100644 index 0000000..5edd83b --- /dev/null +++ b/modules/nixfiles/monitoring/default.nix @@ -0,0 +1,81 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.nixfiles.modules.monitoring; +in { + options.nixfiles.modules.monitoring.enable = mkEnableOption "custom monitoring stack"; + + config = mkIf cfg.enable { + nixfiles.modules = { + grafana.enable = true; + loki.enable = true; + prometheus.enable = true; + alertmanager.enable = true; + }; + + services = { + grafana.provision = { + enable = true; + + datasources = with config.nixfiles.modules; [ + { + name = "Prometheus"; + type = "prometheus"; + access = "proxy"; + url = "https://${prometheus.domain}"; + isDefault = true; + } + { + name = "Loki"; + type = "loki"; + access = "proxy"; + url = "https://${loki.domain}"; + } + ]; + + # TODO Move dashboards to this repository. + dashboards = [ + { + name = "system"; + options.path = pkgs.fetchurl { + url = "https://gist.githubusercontent.com/azahi/b8951223e6850d88159b0c34749a20aa/raw/00c6928374b5d231dc3afe617165550868b8c233/System-1645616603173.json"; + sha256 = "sha256-vGlCOHT5Rp1K88Z8lkLGkvTDeFpgi967CSOb/797vwY="; + }; + } + { + name = "endlessh-go"; + options.path = pkgs.fetchurl { + url = "https://gist.githubusercontent.com/azahi/fd917e917fb53deacf3c6d7366bae2b2/raw/796530bd899e9328e423d18a462faf3c7d01c823/endlessh.json"; + sha256 = "sha256-/wJDiFlrHEa1f82pDFtG/T2GRKGlAur0dlQ8eeVJ3m4="; + }; + } + { + name = "unbound"; + options.path = ./dashboards/unbound.json; + } + { + name = "nginx"; + options.path = ./dashboards/nginx.json; + } + { + name = "postgersql"; + options.path = ./dashboards/postgresql.json; + } + ]; + }; + + loki.configuration.ruler.alertmanager_url = "https://${config.nixfiles.modules.alertmanager.domain}"; + + prometheus.alertmanagers = [ + { + scheme = "https"; + static_configs = [{targets = [config.nixfiles.modules.alertmanager.domain];}]; + } + ]; + }; + }; +} |