diff options
| author | seth <[email protected]> | 2023-08-05 03:27:45 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2023-08-05 03:29:57 -0400 |
| commit | 328cc0182336b8b394702b02c4e0f6255a7174a2 (patch) | |
| tree | 7b1b5b9a7ae95bafd7a1606420d13f634be5ed09 /hosts | |
| parent | 1b8d2d2ba704aedcdc6cad0faca7c8b689d314a8 (diff) | |
hosts!: prometheus -> victoria metrics
Diffstat (limited to 'hosts')
| -rw-r--r-- | hosts/atlas/default.nix | 2 | ||||
| -rw-r--r-- | hosts/atlas/prometheus.nix | 14 | ||||
| -rw-r--r-- | hosts/p-body/default.nix | 2 | ||||
| -rw-r--r-- | hosts/p-body/prometheus.nix | 32 | ||||
| -rw-r--r-- | hosts/p-body/victoriametrics.nix | 26 | ||||
| -rw-r--r-- | hosts/profiles.nix | 14 |
6 files changed, 41 insertions, 49 deletions
diff --git a/hosts/atlas/default.nix b/hosts/atlas/default.nix index a77d6ec..1a9691d 100644 --- a/hosts/atlas/default.nix +++ b/hosts/atlas/default.nix @@ -7,7 +7,6 @@ ./hardware-configuration.nix ./miniflux.nix ./nginx.nix - ./prometheus.nix ]; _module.args.nixinate = { @@ -30,6 +29,7 @@ networking = { domain = "mydadleft.me"; hostName = "atlas"; + firewall.allowedTCPPorts = [config.services.prometheus.exporters.node.port]; }; nix.settings.allowed-users = ["bob"]; diff --git a/hosts/atlas/prometheus.nix b/hosts/atlas/prometheus.nix deleted file mode 100644 index 041c407..0000000 --- a/hosts/atlas/prometheus.nix +++ /dev/null @@ -1,14 +0,0 @@ -{config, ...}: { - networking.firewall.allowedTCPPorts = [config.services.prometheus.exporters.node.port]; - - services.prometheus.exporters.node = { - enable = true; - enabledCollectors = ["systemd"]; - }; - - getchoo.server.services.promtail.clients = [ - { - url = "http://p-body:3030/loki/api/v1/push"; - } - ]; -} diff --git a/hosts/p-body/default.nix b/hosts/p-body/default.nix index 06baded..c1d4dca 100644 --- a/hosts/p-body/default.nix +++ b/hosts/p-body/default.nix @@ -11,7 +11,7 @@ ./grafana.nix ./loki.nix ./nginx.nix - ./prometheus.nix + ./victoriametrics.nix ]; _module.args.nixinate = { diff --git a/hosts/p-body/prometheus.nix b/hosts/p-body/prometheus.nix deleted file mode 100644 index 26e9d0e..0000000 --- a/hosts/p-body/prometheus.nix +++ /dev/null @@ -1,32 +0,0 @@ -{config, ...}: let - scrapeExporter = name: host: port: { - job_name = "${name}"; - static_configs = [ - { - targets = [ - "${host}:${port}" - ]; - } - ]; - }; -in { - services.prometheus = { - enable = true; - exporters = { - node = { - enable = true; - enabledCollectors = ["systemd"]; - }; - }; - scrapeConfigs = [ - (scrapeExporter "p-body" "localhost" "${toString config.services.prometheus.exporters.node.port}") - (scrapeExporter "atlas" "atlas" "${toString config.services.prometheus.exporters.node.port}") - ]; - }; - - getchoo.server.services.promtail.clients = [ - { - url = "http://localhost:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push"; - } - ]; -} diff --git a/hosts/p-body/victoriametrics.nix b/hosts/p-body/victoriametrics.nix new file mode 100644 index 0000000..dec893e --- /dev/null +++ b/hosts/p-body/victoriametrics.nix @@ -0,0 +1,26 @@ +{config, ...}: let + mkScrapes = let + mkConfig = client: { + job_name = "${client}"; + static_configs = [ + { + targets = [ + "${client}:${toString config.services.prometheus.exporters.node.port}" + ]; + } + ]; + }; + in + builtins.map mkConfig; +in { + services = { + victoriametrics.enable = true; + + vmagent = { + enable = true; + prometheusConfig = { + scrape_configs = mkScrapes ["p-body" "atlas"]; + }; + }; + }; +} diff --git a/hosts/profiles.nix b/hosts/profiles.nix index 5b200c2..ae25d91 100644 --- a/hosts/profiles.nix +++ b/hosts/profiles.nix @@ -103,10 +103,22 @@ in { server = { enable = true; - services.promtail.enable = true; + services.promtail = { + enable = true; + clients = [ + { + url = "http://p-body:3030/loki/api/v1/push"; + } + ]; + }; }; }; + services.prometheus.exporters.node = { + enable = true; + enabledCollectors = ["systemd"]; + }; + nix.registry.nixpkgs.flake = nixpkgs-stable; system.stateVersion = "23.05"; } |
