diff options
author | Rory& <root@rory.gay> | 2024-12-24 05:11:46 +0100 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-12-24 05:11:46 +0100 |
commit | ebda96ad32f459fb1b9f135dcde810b332110673 (patch) | |
tree | 2ba5302466949b8cc211604bb85890b46662baa5 | |
parent | Move redpanda on Rory-nginx to port 5100 (diff) | |
download | Rory-Open-Architecture-ebda96ad32f459fb1b9f135dcde810b332110673.tar.xz |
Clean up redpanda configuration, add prometheus scrape config
-rwxr-xr-x | host/Rory-nginx/configuration.nix | 91 | ||||
-rw-r--r-- | host/Rory-nginx/services/redpanda/root.nix | 10 | ||||
-rw-r--r-- | host/Rory-nginx/services/redpanda/systemd-services.nix | 102 |
3 files changed, 112 insertions, 91 deletions
diff --git a/host/Rory-nginx/configuration.nix b/host/Rory-nginx/configuration.nix index f1ce3f9..33299f6 100755 --- a/host/Rory-nginx/configuration.nix +++ b/host/Rory-nginx/configuration.nix @@ -103,95 +103,4 @@ environment.systemPackages = with pkgs; [ waypipe ]; nix.nrBuildUsers = 128; - - services.redpanda-connect = { - enable = true; - pipelines = { - systemd-services = { - enable = true; - allowSudo = true; - config = { - http = { - enabled = true; - address = "127.0.0.1:5100"; - }; - input = { - label = ""; - subprocess = { - name = "sudo"; - args = [ - "systemctl" - "-ojson" - "--recursive" - ]; - restart_on_exit = true; - }; - }; - pipeline = { - processors = [ - { unarchive.format = "json_array"; } - { - 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 - } - ''; - } - { - metric = { - name = "systed_service_status"; - type = "gauge"; - value = "\${!json(\"loaded_value\")}"; - labels = { - field = "loaded"; - service = "\${!json(\"unit\")}"; - description = "\${!json(\"description\")}"; - }; - }; - } - { - metric = { - name = "systed_service_status"; - type = "gauge"; - value = "\${!json(\"active_value\")}"; - labels = { - field = "active"; - service = "\${!json(\"unit\")}"; - description = "\${!json(\"description\")}"; - }; - }; - } - { - metric = { - name = "systed_service_status"; - type = "gauge"; - value = "\${!json(\"sub_value\")}"; - labels = { - field = "sub"; - service = "\${!json(\"unit\")}"; - description = "\${!json(\"description\")}"; - }; - }; - } - ]; - }; - metrics.prometheus = { }; - output.drop = { }; - }; - }; - }; - }; } diff --git a/host/Rory-nginx/services/redpanda/root.nix b/host/Rory-nginx/services/redpanda/root.nix new file mode 100644 index 0000000..ad6e976 --- /dev/null +++ b/host/Rory-nginx/services/redpanda/root.nix @@ -0,0 +1,10 @@ +{ ... }: +{ + imports = [ + ./systemd-services.nix + ]; + + services.redpanda = { + enable = true; + }; +} \ No newline at end of file diff --git a/host/Rory-nginx/services/redpanda/systemd-services.nix b/host/Rory-nginx/services/redpanda/systemd-services.nix new file mode 100644 index 0000000..797cb31 --- /dev/null +++ b/host/Rory-nginx/services/redpanda/systemd-services.nix @@ -0,0 +1,102 @@ +{ ... }: +{ + services.redpanda-connect.pipelines.systemd-services = { + enable = true; + allowSudo = true; + config = { + http = { + enabled = true; + address = "127.0.0.1:5100"; + }; + input = { + label = ""; + subprocess = { + name = "sudo"; + args = [ + "systemctl" + "-ojson" + "--recursive" + ]; + restart_on_exit = true; + }; + }; + pipeline = { + processors = [ + { unarchive.format = "json_array"; } + { + 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 + } + ''; + } + { + metric = { + name = "systed_service_status"; + type = "gauge"; + value = "\${!json(\"loaded_value\")}"; + labels = { + field = "loaded"; + service = "\${!json(\"unit\")}"; + description = "\${!json(\"description\")}"; + }; + }; + } + { + metric = { + name = "systed_service_status"; + type = "gauge"; + value = "\${!json(\"active_value\")}"; + labels = { + field = "active"; + service = "\${!json(\"unit\")}"; + description = "\${!json(\"description\")}"; + }; + }; + } + { + metric = { + name = "systed_service_status"; + type = "gauge"; + value = "\${!json(\"sub_value\")}"; + labels = { + field = "sub"; + service = "\${!json(\"unit\")}"; + description = "\${!json(\"description\")}"; + }; + }; + } + ]; + }; + metrics.prometheus = { }; + output.drop = { }; + }; + }; + + services.prometheus.scrapeConfigs = [ + { + job_name = "redpanda-connect"; + scrape_interval = "5s"; + static_configs = [ + { + targets = [ "localhost:5100" ]; + labels.instance = "redpanda-connect"; + } + ]; + metrics_path = "/metrics"; + } + ]; +} |