summaryrefslogtreecommitdiff
path: root/systems/atlas/victoria-metrics.nix
diff options
context:
space:
mode:
Diffstat (limited to 'systems/atlas/victoria-metrics.nix')
-rw-r--r--systems/atlas/victoria-metrics.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/systems/atlas/victoria-metrics.nix b/systems/atlas/victoria-metrics.nix
new file mode 100644
index 0000000..25f0e57
--- /dev/null
+++ b/systems/atlas/victoria-metrics.nix
@@ -0,0 +1,52 @@
+{
+ lib,
+ inputs,
+ ...
+}:
+
+let
+ usesNodeExporter = system: system.config.services.prometheus.exporters.node.enable;
+
+ nodeExporterFrom =
+ system:
+ "http://${system.config.networking.hostName}:${toString system.config.services.prometheus.exporters.node.port}";
+
+ toNodeStaticConfig = system: {
+ targets = [ (nodeExporterFrom system) ];
+ labels.type = "node";
+ };
+
+ remoteNodes = lib.mapAttrsToList (lib.const toNodeStaticConfig) (
+ lib.filterAttrs (lib.const usesNodeExporter) inputs.self.nixosConfigurations
+ );
+in
+
+{
+ borealis = {
+ victorialogs = {
+ enable = true;
+ };
+ };
+
+ services = {
+ journald.upload.enable = true;
+
+ prometheus.exporters.node.enable = true;
+
+ victoriametrics = {
+ enable = true;
+
+ retentionPeriod = "7d";
+
+ prometheusConfig = {
+ scrape_configs = [
+ {
+ job_name = "node-exporter";
+ metrics_path = "/metrics";
+ static_configs = remoteNodes;
+ }
+ ];
+ };
+ };
+ };
+}