about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--hosts/carmel/default.nix1
-rw-r--r--hosts/carmel/services.nix6
-rw-r--r--hosts/tahoe/default.nix1
-rw-r--r--hosts/tahoe/services.nix1
-rw-r--r--modules/services/monitoring/default.nix1
-rw-r--r--modules/services/monitoring/promtail.nix65
-rw-r--r--profiles/monitoring/promtail.nix54
7 files changed, 56 insertions, 73 deletions
diff --git a/hosts/carmel/default.nix b/hosts/carmel/default.nix
index b50c036..67c768b 100644
--- a/hosts/carmel/default.nix
+++ b/hosts/carmel/default.nix
@@ -10,6 +10,7 @@
     "${self}/profiles/nginx.nix"
     "${self}/profiles/router.nix"
     "${self}/profiles/monitoring/exporter.nix"
+    "${self}/profiles/monitoring/promtail.nix"
   ];
 
   boot.loader.efi.efiSysMountPoint = "/boot/efi";
diff --git a/hosts/carmel/services.nix b/hosts/carmel/services.nix
index 5b6055e..6694950 100644
--- a/hosts/carmel/services.nix
+++ b/hosts/carmel/services.nix
@@ -1,10 +1,4 @@
 { config, pkgs, ... }: {
-  my.services = {
-    monitoring = {
-      promtail.enable = true;
-    };
-  };
-
   services.nginx = {
     streamConfig = ''
       server {
diff --git a/hosts/tahoe/default.nix b/hosts/tahoe/default.nix
index a5a6533..a23c7c8 100644
--- a/hosts/tahoe/default.nix
+++ b/hosts/tahoe/default.nix
@@ -18,6 +18,7 @@ in
     "${self}/profiles/music-server.nix"
     "${self}/profiles/hardware/amd.nix"
     "${self}/profiles/monitoring/exporter.nix"
+    "${self}/profiles/monitoring/promtail.nix"
   ];
 
   # Use systemd-networkd for networking
diff --git a/hosts/tahoe/services.nix b/hosts/tahoe/services.nix
index b8745e4..a8b80b8 100644
--- a/hosts/tahoe/services.nix
+++ b/hosts/tahoe/services.nix
@@ -20,7 +20,6 @@ in
         enable = true;
         vhostName = "dash.${config.homelab.domain}";
       };
-      promtail.enable = true;
     };
 
     sendsms.enable = true;
diff --git a/modules/services/monitoring/default.nix b/modules/services/monitoring/default.nix
index fe1e219..32866cb 100644
--- a/modules/services/monitoring/default.nix
+++ b/modules/services/monitoring/default.nix
@@ -7,6 +7,5 @@ in
     ./grafana.nix
     ./loki.nix
     ./prometheus.nix
-    ./promtail.nix
   ];
 }
diff --git a/modules/services/monitoring/promtail.nix b/modules/services/monitoring/promtail.nix
deleted file mode 100644
index 85d34dc..0000000
--- a/modules/services/monitoring/promtail.nix
+++ /dev/null
@@ -1,65 +0,0 @@
-{ config, lib, pkgs, ... }:
-let
-  cfg = config.my.services.monitoring.promtail;
-in
-{
-  options.my.services.monitoring.promtail = with lib; {
-    enable = mkEnableOption "promtail logs exporter";
-  };
-
-  config = lib.mkIf cfg.enable {
-    services.promtail = {
-      enable = true;
-      configuration = {
-        clients = [{ url = "http://192.168.6.40:3100/loki/api/v1/push"; }];
-        scrape_configs = [
-          {
-            job_name = "journal";
-            journal = {
-              json = true;
-              path = "/var/log/journal";
-              max_age = "12h";
-              labels = {
-                host = config.networking.hostName;
-                job = "journal";
-                "__path__" = "/var/log/journal";
-              };
-            };
-
-            relabel_configs = [
-              {
-                source_labels = [ "__journal__systemd_unit" ];
-                target_label = "unit";
-              }
-              {
-                source_labels = [ "__journal_priority" ];
-                target_label = "priority";
-              }
-              {
-                source_labels = [ "__journal_syslog_identifier" ];
-                target_label = "syslog_id";
-              }
-            ];
-          }
-
-          {
-            job_name = "nginx";
-            static_configs = [{
-              labels = {
-                host = config.networking.hostName;
-                job = "nginx";
-                __path__ = "/var/log/nginx/*";
-              };
-            }];
-          }
-        ];
-
-        server = {
-          http_listen_port = 9832;
-          http_path_prefix = "/promtail";
-          grpc_listen_port = 0;
-        };
-      };
-    };
-  };
-}
diff --git a/profiles/monitoring/promtail.nix b/profiles/monitoring/promtail.nix
new file mode 100644
index 0000000..23b6669
--- /dev/null
+++ b/profiles/monitoring/promtail.nix
@@ -0,0 +1,54 @@
+{ config, lib, pkgs, ... }:
+{
+  services.promtail.enable = true;
+  services.promtail.configuration = {
+    clients = [{ url = "https://loki.${config.homelab.domain}:3100/loki/api/v1/push"; }];
+    scrape_configs = [
+      {
+        job_name = "journal";
+        journal = {
+          json = true;
+          path = "/var/log/journal";
+          max_age = "12h";
+          labels = {
+            host = config.networking.hostName;
+            job = "journal";
+            "__path__" = "/var/log/journal";
+          };
+        };
+
+        relabel_configs = [
+          {
+            source_labels = [ "__journal__systemd_unit" ];
+            target_label = "unit";
+          }
+          {
+            source_labels = [ "__journal_priority" ];
+            target_label = "priority";
+          }
+          {
+            source_labels = [ "__journal_syslog_identifier" ];
+            target_label = "syslog_id";
+          }
+        ];
+      }
+
+      {
+        job_name = "nginx";
+        static_configs = [{
+          labels = {
+            host = config.networking.hostName;
+            job = "nginx";
+            __path__ = "/var/log/nginx/*";
+          };
+        }];
+      }
+    ];
+
+    server = {
+      http_listen_port = 9832;
+      http_path_prefix = "/promtail";
+      grpc_listen_port = 0;
+    };
+  };
+}