summaryrefslogtreecommitdiff
path: root/modules/nixos/services/promtail.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2023-10-30 04:22:32 -0400
committerseth <[email protected]>2023-10-30 09:46:15 +0000
commit10b0df38b4286237b56ff9177f8d4c5676bfb5c1 (patch)
treeab298c74339bf9bc41571fa88746ecd9c522fbdf /modules/nixos/services/promtail.nix
parent4c2c60a4f2b14c1e6ffaffe5e301dc31ac4fed0f (diff)
tree-wide: refactor
i went overboard on modules. this is much comfier
Diffstat (limited to 'modules/nixos/services/promtail.nix')
-rw-r--r--modules/nixos/services/promtail.nix47
1 files changed, 47 insertions, 0 deletions
diff --git a/modules/nixos/services/promtail.nix b/modules/nixos/services/promtail.nix
new file mode 100644
index 0000000..63faf15
--- /dev/null
+++ b/modules/nixos/services/promtail.nix
@@ -0,0 +1,47 @@
+{
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.server.services.promtail;
+ inherit (lib) mkEnableOption mkIf mkOption types;
+in {
+ options.server.services.promtail = {
+ enable = mkEnableOption "enable promtail";
+
+ clients = mkOption {
+ type = types.listOf types.attrs;
+ default = [{}];
+ description = "clients for promtail";
+ };
+ };
+
+ config.services.promtail = mkIf cfg.enable {
+ enable = true;
+ configuration = {
+ inherit (cfg) clients;
+ server.disable = true;
+
+ scrape_configs = [
+ {
+ job_name = "journal";
+
+ journal = {
+ max_age = "12h";
+ labels = {
+ job = "systemd-journal";
+ host = "${config.networking.hostName}";
+ };
+ };
+
+ relabel_configs = [
+ {
+ source_labels = ["__journal__systemd_unit"];
+ target_label = "unit";
+ }
+ ];
+ }
+ ];
+ };
+ };
+}