summaryrefslogtreecommitdiff
path: root/modules/nixos/mixins/promtail.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2024-10-27 20:12:19 -0400
committerGitHub <[email protected]>2024-10-28 00:12:19 +0000
commit5ec7ee21e036f7bc1cbdec714271c619cb3fdb3d (patch)
tree3277d8ba68ca466e68c58a8373063010db392d2e /modules/nixos/mixins/promtail.nix
parent75ec48c5f7dd7877f2294b86764b1fdadc6b7e88 (diff)
modules: restructure (#487)
* seth: remove unused pkgs * modules: restructure from archetypes back to profiles make less actual modules for everything use lib.mkDefault like it's supposed to move mixins out of server * nixos/resolved: use modern options
Diffstat (limited to 'modules/nixos/mixins/promtail.nix')
-rw-r--r--modules/nixos/mixins/promtail.nix48
1 files changed, 48 insertions, 0 deletions
diff --git a/modules/nixos/mixins/promtail.nix b/modules/nixos/mixins/promtail.nix
new file mode 100644
index 0000000..022c271
--- /dev/null
+++ b/modules/nixos/mixins/promtail.nix
@@ -0,0 +1,48 @@
+{ config, lib, ... }:
+let
+ cfg = config.mixins.promtail;
+ inherit (lib) types;
+in
+{
+ options.mixins.promtail = {
+ enable = lib.mkEnableOption "Promtail mixin";
+
+ clients = lib.mkOption {
+ type = types.listOf types.attrs;
+ default = [ { } ];
+ defaultText = lib.literalExpression "[ { } ]";
+ description = "Clients for promtail";
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ services.promtail = {
+ 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";
+ }
+ ];
+ }
+ ];
+ };
+ };
+ };
+}