diff options
author | Azat Bahawi <azat@bahawi.net> | 2024-03-31 21:29:27 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2024-03-31 21:29:27 +0300 |
commit | 9a5427e3a0c0ccf2a82dc503149a26b23fbd6004 (patch) | |
tree | f28beec29deeea36038615a8fb98a810891940b5 /modules/nixos/promtail.nix | |
parent | 2024-03-19 (diff) |
2024-03-31
Diffstat (limited to '')
-rw-r--r-- | modules/nixos/promtail.nix | 109 |
1 files changed, 57 insertions, 52 deletions
diff --git a/modules/nixos/promtail.nix b/modules/nixos/promtail.nix index 28dc897..65d88d4 100644 --- a/modules/nixos/promtail.nix +++ b/modules/nixos/promtail.nix @@ -4,9 +4,11 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.promtail; -in { +in +{ options.nixfiles.modules.promtail = { enable = mkEnableOption "Promtail"; @@ -25,7 +27,7 @@ in { filters = mkOption { description = ''Filters to use with "scrape_config.pipeline_stages".''; type = with types; listOf attrs; - default = []; + default = [ ]; }; }; @@ -64,60 +66,63 @@ in { job_name = "journal"; journal.max_age = "24h"; relabel_configs = - map (n: let - label = toLower n; - in { - source_labels = ["__journal_${label}"]; - target_label = - if hasPrefix "_" label - then substring 1 (stringLength label - 1) label - else label; - }) [ - # Derived from systemd.journal fields[1]. - # - # [1]: https://github.com/coreos/go-systemd/blob/main/sdjournal/journal.go#L335 - # [1]: https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html + map + ( + n: + let + label = toLower n; + in + { + source_labels = [ "__journal_${label}" ]; + target_label = if hasPrefix "_" label then substring 1 (stringLength label - 1) label else label; + } + ) + [ + # Derived from systemd.journal fields[1]. + # + # [1]: https://github.com/coreos/go-systemd/blob/main/sdjournal/journal.go#L335 + # [1]: https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html - "MESSAGE" - # "MESSAGE_ID" - "PRIORITY" - # "CODE_FILE" - # "CODE_LINE" - # "CODE_FUNC" - # "ERRNO" - "SYSLOG_FACILITY" - "SYSLOG_IDENTIFIER" - # "SYSLOG_PID" - # "_PID" - # "_UID" - # "_GID" - # "_COMM" - # "_EXE" - "_CMDLINE" - # "_CAP_EFFECTIVE" - # "_AUDIT_SESSION" - # "_AUDIT_LOGINUID" - # "_SYSTEMD_CGROUP" - # "_SYSTEMD_SESSION" - # "_SYSTEMD_UNIT" - # "_SYSTEMD_USER_UNIT" - # "_SYSTEMD_OWNER_UID" - # "_SYSTEMD_SLICE" - # "_SELINUX_CONTEXT" - # "_SOURCE_REALTIME_TIMESTAMP" - # "_BOOT_ID" - # "_MACHINE_ID" - "_HOSTNAME" - # "_TRANSPORT" - # "__CURSOR" - # "__REALTIME_TIMESTAMP" - # "__MONOTONIC_TIMESTAMP" - ] + "MESSAGE" + # "MESSAGE_ID" + "PRIORITY" + # "CODE_FILE" + # "CODE_LINE" + # "CODE_FUNC" + # "ERRNO" + "SYSLOG_FACILITY" + "SYSLOG_IDENTIFIER" + # "SYSLOG_PID" + # "_PID" + # "_UID" + # "_GID" + # "_COMM" + # "_EXE" + "_CMDLINE" + # "_CAP_EFFECTIVE" + # "_AUDIT_SESSION" + # "_AUDIT_LOGINUID" + # "_SYSTEMD_CGROUP" + # "_SYSTEMD_SESSION" + # "_SYSTEMD_UNIT" + # "_SYSTEMD_USER_UNIT" + # "_SYSTEMD_OWNER_UID" + # "_SYSTEMD_SLICE" + # "_SELINUX_CONTEXT" + # "_SOURCE_REALTIME_TIMESTAMP" + # "_BOOT_ID" + # "_MACHINE_ID" + "_HOSTNAME" + # "_TRANSPORT" + # "__CURSOR" + # "__REALTIME_TIMESTAMP" + # "__MONOTONIC_TIMESTAMP" + ] ++ [ { # This is weird. I can't find where is this defined in the # source code but apparently it exists. - source_labels = ["__journal_priority_keyword"]; + source_labels = [ "__journal_priority_keyword" ]; target_label = "level"; } ]; |