diff options
| author | Martin Fischer <martin@push-f.com> | 2025-12-14 22:44:31 +0100 |
|---|---|---|
| committer | Martin Fischer <martin@push-f.com> | 2025-12-14 23:12:56 +0100 |
| commit | ef15d5aad7360ee6811cc3fa09ca8106a7f09fb6 (patch) | |
| tree | 999f19b39ae4b0390bda4bd20f05e45b028b2e8f /nixos/shared | |
| parent | de4843c5002f3f58f8bc69dd57d368324b67f4ce (diff) | |
feat: add prometheus-storagebox-exporter
Diffstat (limited to 'nixos/shared')
| -rw-r--r-- | nixos/shared/prometheus-storagebox-exporter/default.nix | 24 | ||||
| -rw-r--r-- | nixos/shared/prometheus-storagebox-exporter/service.nix | 33 |
2 files changed, 57 insertions, 0 deletions
diff --git a/nixos/shared/prometheus-storagebox-exporter/default.nix b/nixos/shared/prometheus-storagebox-exporter/default.nix new file mode 100644 index 0000000..281290f --- /dev/null +++ b/nixos/shared/prometheus-storagebox-exporter/default.nix @@ -0,0 +1,24 @@ +{ + lib, + buildGoModule, +}: +let + sources = import <top/npins>; +in +buildGoModule { + pname = "storagebox_exporter"; + version = sources.prometheus-storagebox-exporter.version; + src = sources.prometheus-storagebox-exporter; + vendorHash = "sha256-3aBklYmPHELcLG+3sOEDd9qkrJyDrC52LfhOOY/6sOc="; + + meta = with lib; { + description = "Modern Prometheus exporter for Hetzner Storage Box with comprehensive metrics"; + mainProgram = "prometheus-storagebox-exporter"; + homepage = "https://github.com/crstian19/prometheus-storagebox-exporter"; + license = licenses.mit; + }; + + postPatch = '' + substituteInPlace go.mod --replace 'go 1.25.5' 'go 1.25.4' + ''; +} diff --git a/nixos/shared/prometheus-storagebox-exporter/service.nix b/nixos/shared/prometheus-storagebox-exporter/service.nix new file mode 100644 index 0000000..74f0dd1 --- /dev/null +++ b/nixos/shared/prometheus-storagebox-exporter/service.nix @@ -0,0 +1,33 @@ +# TODO: submit Christian's storagebox exporter to nixpkgs +{ config, lib, pkgs, ... }: + +let + storageboxExporter = pkgs.callPackage ./default.nix {}; + cfg = config.services.prometheus-storagebox-exporter; +in +{ + options.services.prometheus-storagebox-exporter = { + enable = lib.mkEnableOption "storagebox-exporter"; + port = lib.mkOption { + type = lib.types.int; + }; + hetznerTokenFile = lib.mkOption { + type = lib.types.path; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.services.storagebox-exporter = { + serviceConfig = { + ExecStart = "${storageboxExporter}/bin/prometheus-storagebox-exporter"; + DynamicUser = "true"; + LoadCredential = "hetznerToken:${cfg.hetznerTokenFile}"; + }; + environment = { + HETZNER_TOKEN_FILE = "%d/hetznerToken"; + LISTEN_ADDRESS = ":${toString cfg.port}"; + }; + wantedBy = ["multi-user.target"]; + }; + }; +} |
