diff --git a/hosts/srv-monitor/default.nix b/hosts/srv-monitor/default.nix index 772be88..80b2b87 100644 --- a/hosts/srv-monitor/default.nix +++ b/hosts/srv-monitor/default.nix @@ -63,8 +63,9 @@ victorialogs.enable = true; }; dashboards = { - nodeExporter.enable = true; - victoriametrics.enable = true; + nodeExporter = true; + victoriametrics = true; + victorialogs = true; }; }; @@ -81,7 +82,10 @@ alloy = { enable = true; domain = "alloy-${config.networking.hostName}.${tailscaleDomain}"; - collect.hostMetrics = true; + collect = { + hostMetrics = true; + victorialogsMetrics = true; + }; }; caddy.virtualHosts = diff --git a/modules/system/services/alloy.nix b/modules/system/services/alloy.nix index 454b1b6..78f9c01 100644 --- a/modules/system/services/alloy.nix +++ b/modules/system/services/alloy.nix @@ -23,6 +23,7 @@ in }; collect = { hostMetrics = lib.mkEnableOption ""; + victorialogsMetrics = lib.mkEnableOption ""; sshdLogs = lib.mkEnableOption ""; }; }; @@ -56,10 +57,10 @@ in } ''; - "alloy/node-exporter.alloy" = lib.mkIf cfg.collect.hostMetrics { + "alloy/host-metrics.alloy" = lib.mkIf cfg.collect.hostMetrics { text = '' prometheus.exporter.unix "default" { - enable_collectors = [ "systemd" ] + enable_collectors = ["systemd"] } prometheus.scrape "node_exporter" { @@ -70,6 +71,18 @@ in ''; }; + "alloy/victorialogs-metrics.alloy" = lib.mkIf cfg.collect.victorialogsMetrics { + text = '' + prometheus.scrape "victorialogs" { + targets = [{ + __address__ = "localhost:${builtins.toString config.custom.services.victorialogs.port}", + }] + forward_to = [prometheus.remote_write.default.receiver] + scrape_interval = "15s" + } + ''; + }; + "alloy/sshd-logs.alloy" = lib.mkIf cfg.collect.sshdLogs { text = '' loki.source.journal "sshd" { diff --git a/modules/system/services/grafana.nix b/modules/system/services/grafana.nix index 95445e3..2024279 100644 --- a/modules/system/services/grafana.nix +++ b/modules/system/services/grafana.nix @@ -42,8 +42,9 @@ in }; }; dashboards = { - nodeExporter.enable = lib.mkEnableOption ""; - victoriametrics.enable = lib.mkEnableOption ""; + nodeExporter = lib.mkEnableOption ""; + victoriametrics = lib.mkEnableOption ""; + victorialogs = lib.mkEnableOption ""; }; }; @@ -122,7 +123,7 @@ in environment.etc = { "grafana-dashboards/node-exporter-full.json" = { - enable = cfg.dashboards.nodeExporter.enable; + enable = cfg.dashboards.nodeExporter; source = pkgs.fetchurl { name = "node-exporter-full.json"; url = "https://grafana.com/api/dashboards/1860/revisions/41/download"; @@ -130,13 +131,21 @@ in }; }; "grafana-dashboards/victoriametrics-single-node.json" = { - enable = cfg.dashboards.victoriametrics.enable; + enable = cfg.dashboards.victoriametrics; source = pkgs.fetchurl { name = "victoriametrics-single-node.json"; url = "https://grafana.com/api/dashboards/10229/revisions/41/download"; hash = "sha256-mwtah8A2w81WZjf5bUXoTJfS1R9UX+tua2PiDrBKJCQ="; }; }; + "grafana-dashboards/victorialogs-single-node.json" = { + enable = cfg.dashboards.victorialogs; + source = pkgs.fetchurl { + name = "victorialogs-single-node.json"; + url = "https://grafana.com/api/dashboards/22084/revisions/8/download"; + hash = "sha256-/a3Rbp/6oyiLBnQtGupyFZW+fIHQfkyKRRTyfofxVTM="; + }; + }; }; }; } diff --git a/modules/system/services/victorialogs.nix b/modules/system/services/victorialogs.nix index ae4c581..63af76c 100644 --- a/modules/system/services/victorialogs.nix +++ b/modules/system/services/victorialogs.nix @@ -46,7 +46,12 @@ in services.victorialogs = { enable = true; - package = pkgs-unstable.victorialogs; + package = pkgs-unstable.victorialogs.overrideAttrs ( + _: previousAttrs: { + version = "victoria-logs-" + previousAttrs.version; + __intentionallyOverridingVersion = true; + } + ); listenAddress = "localhost:${builtins.toString cfg.port}"; extraOptions = [ "-retention.maxDiskSpaceUsageBytes=${cfg.maxDiskSpaceUsage}" ]; };