summaryrefslogtreecommitdiff
path: root/modules/nixos/server/services/promtail.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2023-05-21 13:46:36 -0400
committerseth <[email protected]>2023-05-21 13:46:36 -0400
commitc6b38fd8f0e5908e5593d33e66cae8980f560c1b (patch)
treecaee5d2585b0e62c3dc26f4bd324ea6cd49aadfe /modules/nixos/server/services/promtail.nix
parented52175975f8f448cd66372c5ff8d3e900fc1541 (diff)
move monitoring setup to modules
Diffstat (limited to 'modules/nixos/server/services/promtail.nix')
-rw-r--r--modules/nixos/server/services/promtail.nix56
1 files changed, 56 insertions, 0 deletions
diff --git a/modules/nixos/server/services/promtail.nix b/modules/nixos/server/services/promtail.nix
new file mode 100644
index 0000000..73a8de2
--- /dev/null
+++ b/modules/nixos/server/services/promtail.nix
@@ -0,0 +1,56 @@
+{
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.getchoo.server.services.promtail;
+ inherit (lib) mkEnableOption mkIf mkOption types;
+in {
+ options.getchoo.server.services.promtail = {
+ enable = mkEnableOption "enable promtail";
+
+ port = mkOption {
+ type = types.port;
+ default = 3031;
+ description = "port for promtail";
+ };
+
+ clients = mkOption {
+ type = types.listOf types.attrs;
+ default = [{}];
+ description = "clients for promtail";
+ };
+ };
+
+ config.services.promtail = mkIf cfg.enable {
+ enable = true;
+ configuration = {
+ server = {
+ http_listen_port = cfg.port;
+ grpc_listen_port = 0;
+ };
+ positions = {
+ filename = "/tmp/positions.yaml";
+ };
+ inherit (cfg) clients;
+ 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";
+ }
+ ];
+ }
+ ];
+ };
+ };
+}