mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-24 22:53:42 +00:00
nixos/victoriametrics: the prometheusConfig option isn't null by default (#361778)
This commit is contained in:
commit
65e0eebf2d
@ -139,7 +139,7 @@ in
|
||||
serviceConfig = {
|
||||
ExecStart = lib.escapeShellArgs (
|
||||
startCLIList
|
||||
++ lib.optionals (cfg.prometheusConfig != null) [ "-promscrape.config=${prometheusConfigYml}" ]
|
||||
++ lib.optionals (cfg.prometheusConfig != {}) [ "-promscrape.config=${prometheusConfigYml}" ]
|
||||
);
|
||||
|
||||
DynamicUser = true;
|
||||
|
@ -115,7 +115,7 @@ in {
|
||||
CacheDirectory = "vmagent";
|
||||
ExecStart = lib.escapeShellArgs (
|
||||
startCLIList
|
||||
++ lib.optionals (cfg.prometheusConfig != null) ["-promscrape.config=${prometheusConfigYml}"]
|
||||
++ lib.optionals (cfg.prometheusConfig != {}) ["-promscrape.config=${prometheusConfigYml}"]
|
||||
);
|
||||
LoadCredential = lib.optional (cfg.remoteWrite.basicAuthPasswordFile != null) [
|
||||
"remote_write_basic_auth_password:${cfg.remoteWrite.basicAuthPasswordFile}"
|
||||
|
@ -7,4 +7,5 @@
|
||||
{
|
||||
remote-write = import ./remote-write.nix { inherit system pkgs; };
|
||||
vmalert = import ./vmalert.nix { inherit system pkgs; };
|
||||
external-promscrape-config = import ./external-promscrape-config.nix { inherit system pkgs; };
|
||||
}
|
||||
|
82
nixos/tests/victoriametrics/external-promscrape-config.nix
Normal file
82
nixos/tests/victoriametrics/external-promscrape-config.nix
Normal file
@ -0,0 +1,82 @@
|
||||
import ../make-test-python.nix (
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
nodeExporterPort = 9100;
|
||||
promscrapeConfig = {
|
||||
global = {
|
||||
scrape_interval = "2s";
|
||||
};
|
||||
scrape_configs = [
|
||||
{
|
||||
job_name = "node";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [
|
||||
"node:${toString nodeExporterPort}"
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
settingsFormat = pkgs.formats.yaml { };
|
||||
promscrapeConfigYaml = settingsFormat.generate "prometheusConfig.yaml" promscrapeConfig;
|
||||
in
|
||||
{
|
||||
name = "victoriametrics-external-promscrape-config";
|
||||
meta = with pkgs.lib.maintainers; {
|
||||
maintainers = [
|
||||
ryan4yin
|
||||
];
|
||||
};
|
||||
|
||||
nodes = {
|
||||
victoriametrics =
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
networking.firewall.allowedTCPPorts = [ 8428 ];
|
||||
services.victoriametrics = {
|
||||
enable = true;
|
||||
extraOptions = [
|
||||
"-promscrape.config=${toString promscrapeConfigYaml}"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
node =
|
||||
{ ... }:
|
||||
{
|
||||
services.prometheus.exporters.node = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
node.wait_for_unit("prometheus-node-exporter")
|
||||
node.wait_for_open_port(${toString nodeExporterPort})
|
||||
|
||||
victoriametrics.wait_for_unit("victoriametrics")
|
||||
victoriametrics.wait_for_open_port(8428)
|
||||
|
||||
|
||||
promscrape_config = victoriametrics.succeed("journalctl -u victoriametrics -o cat | grep 'promscrape.config'")
|
||||
assert '${toString promscrapeConfigYaml}' in promscrape_config
|
||||
|
||||
victoriametrics.wait_until_succeeds(
|
||||
"curl -sf 'http://localhost:8428/api/v1/query?query=node_exporter_build_info\{instance=\"node:9100\"\}' | "
|
||||
+ "jq '.data.result[0].value[1]' | grep '\"1\"'"
|
||||
)
|
||||
'';
|
||||
}
|
||||
)
|
Loading…
Reference in New Issue
Block a user