diff --git a/hosts/services/configuration.nix b/hosts/services/configuration.nix index fc961ae..37d2d3c 100644 --- a/hosts/services/configuration.nix +++ b/hosts/services/configuration.nix @@ -1,6 +1,7 @@ { ... }: { imports = [ ./hardware-configuration.nix + ./firewall-services.nix ../modules/users.nix ../modules/common.nix ../modules/grafana.nix diff --git a/modules/grafana.nix b/modules/grafana.nix index 1a18162..533033e 100644 --- a/modules/grafana.nix +++ b/modules/grafana.nix @@ -1,35 +1,54 @@ { config, pkgs, ...}: -let - caddyDir = "/var/lib/caddy"; -in -{ -services.grafana = { - enable = true; - domain = "sup.atlanticaweb"; - port = 2342; - addr = "127.0.0.1"; - }; -services.caddy = { - enable = true; - email = "lucazeau.alexandre@gmail.com"; - config = '' + let + caddyDir = "/var/lib/caddy"; + in { - storage file_system { - root ${caddyDir} + services.grafana = { + enable = true; + domain = "sup.atlanticaweb.fr"; + port = 2342; + addr = "127.0.0.1"; + }; + services.caddy = { + enable = true; + email = "lucazeau.alexandre@gmail.com"; + extraConfig = '' + { + storage file_system { + root ${caddyDir} + } } - } - https://grafana.atlanticaweb.fr { - reverse_proxy http://127.0.0.1:${toString config.services.grafana.port} - } - ''; -}; -users.users.caddy = { - group = "caddy"; - uid = config.ids.uids.caddy; - home = caddyDir; - createHome = true; - extraGroups = [ "users" ]; -}; - -users.groups.caddy.gid = config.ids.uids.caddy; + https://sup.atlanticaweb.fr:2342 { + reverse_proxy http://127.0.0.1:${toString config.services.grafana.port} + } + ''; + }; + services.prometheus = { + enable = true; + port = 9001; + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; + port = 9002; + }; + }; + scrapeConfigs = [ + { + job_name = "services"; + static_configs = [{ + targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; + }]; + } + ]; + }; + users.users.caddy = { + group = "caddy"; + uid = config.ids.uids.caddy; + home = caddyDir; + createHome = true; + extraGroups = [ "users" ]; + }; + + users.groups.caddy.gid = config.ids.uids.caddy; }