mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Merge pull request #318659 from mweinelt/fastly-exporter
nixos/prometheus-fastly-exporter: unwrap execstart
This commit is contained in:
commit
84164bf098
2 changed files with 25 additions and 21 deletions
|
@ -1,17 +1,20 @@
|
||||||
{ config
|
{
|
||||||
, lib
|
config,
|
||||||
, pkgs
|
lib,
|
||||||
, options
|
pkgs,
|
||||||
, ...
|
utils,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
escapeShellArgs
|
getExe
|
||||||
mkOption
|
mkOption
|
||||||
optionals
|
optionals
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
|
|
||||||
|
inherit (utils) escapeSystemdExecArgs;
|
||||||
|
|
||||||
cfg = config.services.prometheus.exporters.fastly;
|
cfg = config.services.prometheus.exporters.fastly;
|
||||||
in
|
in
|
||||||
|
@ -39,17 +42,19 @@ in
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
LoadCredential = "fastly-api-token:${cfg.tokenPath}";
|
LoadCredential = "fastly-api-token:${cfg.tokenPath}";
|
||||||
|
Environment = [ "FASTLY_API_TOKEN=%d/fastly-api-token" ];
|
||||||
|
ExecStart = escapeSystemdExecArgs (
|
||||||
|
[
|
||||||
|
(getExe pkgs.prometheus-fastly-exporter)
|
||||||
|
"-listen"
|
||||||
|
"${cfg.listenAddress}:${toString cfg.port}"
|
||||||
|
]
|
||||||
|
++ optionals (cfg.configFile != null) [
|
||||||
|
"--config-file"
|
||||||
|
cfg.configFile
|
||||||
|
]
|
||||||
|
++ cfg.extraFlags
|
||||||
|
);
|
||||||
};
|
};
|
||||||
script = let
|
|
||||||
call = escapeShellArgs ([
|
|
||||||
"${pkgs.prometheus-fastly-exporter}/bin/fastly-exporter"
|
|
||||||
"-listen" "${cfg.listenAddress}:${toString cfg.port}"
|
|
||||||
] ++ optionals (cfg.configFile != null) [
|
|
||||||
"--config-file" cfg.configFile
|
|
||||||
] ++ cfg.extraFlags);
|
|
||||||
in ''
|
|
||||||
export FASTLY_API_TOKEN="$(cat $CREDENTIALS_DIRECTORY/fastly-api-token)"
|
|
||||||
${call}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,10 +314,9 @@ let
|
||||||
tokenPath = pkgs.writeText "token" "abc123";
|
tokenPath = pkgs.writeText "token" "abc123";
|
||||||
};
|
};
|
||||||
|
|
||||||
# noop: fastly's exporter can't start without first talking to fastly
|
|
||||||
# see: https://github.com/peterbourgon/fastly-exporter/issues/87
|
|
||||||
exporterTest = ''
|
exporterTest = ''
|
||||||
succeed("true");
|
wait_for_unit("prometheus-fastly-exporter.service")
|
||||||
|
wait_for_open_port(9118)
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue