summary refs log tree commit diff
diff options
context:
space:
mode:
authorKinoshita Shimizu <ks@kinoshitaproductions.com>2024-12-31 14:42:18 -0600
committerKinoshita Shimizu <ks@kinoshitaproductions.com>2024-12-31 14:42:18 -0600
commit3a0db7ec306cda487fdba71580b04b81f6740bff (patch)
tree8b27f5efcb146b2a0633e458b38676013b05818e
parentSystemd, not systed lol (diff)
downloadRory-Open-Architecture-tune-redpanda.tar.xz
Use generate + command instead of subprocess, focus on active value only and add instance label tune-redpanda
-rw-r--r--host/Rory-nginx/services/redpanda/systemd-services.nix72
1 files changed, 21 insertions, 51 deletions
diff --git a/host/Rory-nginx/services/redpanda/systemd-services.nix b/host/Rory-nginx/services/redpanda/systemd-services.nix

index bb13e53..58e8ed0 100644 --- a/host/Rory-nginx/services/redpanda/systemd-services.nix +++ b/host/Rory-nginx/services/redpanda/systemd-services.nix
@@ -9,16 +9,18 @@ address = "127.0.0.1:5100"; }; input = { - label = ""; - subprocess = { - name = "${pkgs.systemd}/bin/systemctl"; - args = [ - "-ojson" - "--recursive" - ]; - restart_on_exit = true; - max_buffer = 1024*512; + generate = { + interval = "@every 5m"; + mapping = "root = \"\""; # Empty string as we do not need to pipe anything to stdin }; + processors = [ + { + command = { + name = "systemctl"; + args_mapping = "[ \"-ojson\", \"--recursive\" ]"; + }; + } + ]; }; pipeline = { processors = [ @@ -26,62 +28,30 @@ { mapping = '' root = this - if this.loaded == "loaded" { - root.loaded_value = 1.0 - } else { - root.loaded_value = 0.0 - } - if this.active == "active" { - root.active_value = 1.0 - } else { - root.active_value = 0.0 - } - if this.sub == "active" { - root.sub_value = 1.0 - } else { - root.sub_value = 0.0 - } + + root.active_value = match { + this.active == "active" => 0.0, + this.active == "reloading" => 1.0, + this.active == "inactive" => 2.0, + this.active == "failed" => 3.0, + this.active == "activating" => 4.0, + this.active == "deactivating" => 5.0, + _ => 0.5, ''; } { metric = { name = "systemd_service_status"; type = "gauge"; - value = "\${!json(\"loaded_value\")}"; - labels = { - field = "loaded"; - service = "\${!json(\"unit\")}"; - description = "\${!json(\"description\")}"; - }; - }; - } - { - metric = { - name = "systemd_service_status"; - type = "gauge"; value = "\${!json(\"active_value\")}"; labels = { field = "active"; service = "\${!json(\"unit\")}"; description = "\${!json(\"description\")}"; + instance = config.networking.hostName; }; }; } - { - metric = { - name = "systemd_service_status"; - type = "gauge"; - value = "\${!json(\"sub_value\")}"; - labels = { - field = "sub"; - service = "\${!json(\"unit\")}"; - description = "\${!json(\"description\")}"; - }; - }; - } - { - sleep.duration = "5s"; - } ]; }; metrics.prometheus = { };