diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2021-07-20 18:01:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 18:01:42 +0000 |
commit | 23c6d36ba0f72916be4c69c9d353a1999c6b01a0 (patch) | |
tree | 1fdbd95e934a9aa66102d69dbb2670e738713e5a /nixos/modules/services/monitoring | |
parent | ab5f5fb163ddc8e285c087a0e984a505ee779b77 (diff) | |
parent | 61eb7e2e9e36e062a3bd323155441f78e9fcd7ed (diff) | |
download | nixpkgs-23c6d36ba0f72916be4c69c9d353a1999c6b01a0.tar nixpkgs-23c6d36ba0f72916be4c69c9d353a1999c6b01a0.tar.gz nixpkgs-23c6d36ba0f72916be4c69c9d353a1999c6b01a0.tar.bz2 nixpkgs-23c6d36ba0f72916be4c69c9d353a1999c6b01a0.tar.lz nixpkgs-23c6d36ba0f72916be4c69c9d353a1999c6b01a0.tar.xz nixpkgs-23c6d36ba0f72916be4c69c9d353a1999c6b01a0.tar.zst nixpkgs-23c6d36ba0f72916be4c69c9d353a1999c6b01a0.zip |
Merge staging-next into staging
Diffstat (limited to 'nixos/modules/services/monitoring')
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters/buildkite-agent.nix | 64 |
2 files changed, 65 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 6bd075697fa..d648de6a414 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -27,6 +27,7 @@ let "bird" "bitcoin" "blackbox" + "buildkite-agent" "collectd" "dnsmasq" "domain" diff --git a/nixos/modules/services/monitoring/prometheus/exporters/buildkite-agent.nix b/nixos/modules/services/monitoring/prometheus/exporters/buildkite-agent.nix new file mode 100644 index 00000000000..7557480ac06 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters/buildkite-agent.nix @@ -0,0 +1,64 @@ +{ config, lib, pkgs, options }: + +with lib; + +let + cfg = config.services.prometheus.exporters.buildkite-agent; +in +{ + port = 9876; + extraOpts = { + tokenPath = mkOption { + type = types.nullOr types.path; + apply = final: if final == null then null else toString final; + description = '' + The token from your Buildkite "Agents" page. + + A run-time path to the token file, which is supposed to be provisioned + outside of Nix store. + ''; + }; + interval = mkOption { + type = types.str; + default = "30s"; + example = "1min"; + description = '' + How often to update metrics. + ''; + }; + endpoint = mkOption { + type = types.str; + default = "https://agent.buildkite.com/v3"; + description = '' + The Buildkite Agent API endpoint. + ''; + }; + queues = mkOption { + type = with types; nullOr (listOf str); + default = null; + example = literalExample ''[ "my-queue1" "my-queue2" ]''; + description = '' + Which specific queues to process. + ''; + }; + }; + serviceOpts = { + script = + let + queues = concatStringsSep " " (map (q: "-queue ${q}") cfg.queues); + in + '' + export BUILDKITE_AGENT_TOKEN="$(cat ${toString cfg.tokenPath})" + exec ${pkgs.buildkite-agent-metrics}/bin/buildkite-agent-metrics \ + -backend prometheus \ + -interval ${cfg.interval} \ + -endpoint ${cfg.endpoint} \ + ${optionalString (cfg.queues != null) queues} \ + -prometheus-addr "${cfg.listenAddress}:${toString cfg.port}" ${concatStringsSep " " cfg.extraFlags} + ''; + serviceConfig = { + DynamicUser = false; + RuntimeDirectory = "buildkite-agent-metrics"; + }; + }; +} |