nixos/thanos: add query-frontend SystemD service
This commit is contained in:
parent
b2c956e071
commit
2074409c86
2 changed files with 35 additions and 0 deletions
|
@ -430,6 +430,12 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
query-frontend = params.common cfg.query-frontend // {
|
||||||
|
query-frontend.downstream-url = mkParamDef types.str "http://localhost:9090" ''
|
||||||
|
URL of downstream Prometheus Query compatible API.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
rule = params.common cfg.rule // params.objstore cfg.rule // {
|
rule = params.common cfg.rule // params.objstore cfg.rule // {
|
||||||
|
|
||||||
labels = mkAttrsParam "label" ''
|
labels = mkAttrsParam "label" ''
|
||||||
|
@ -684,6 +690,13 @@ in {
|
||||||
arguments = mkArgumentsOption "query";
|
arguments = mkArgumentsOption "query";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
query-frontend = paramsToOptions params.query-frontend // {
|
||||||
|
enable = mkEnableOption
|
||||||
|
(lib.mdDoc ("the Thanos query frontend implements a service deployed in front of queriers to
|
||||||
|
improve query parallelization and caching."));
|
||||||
|
arguments = mkArgumentsOption "query-frontend";
|
||||||
|
};
|
||||||
|
|
||||||
rule = paramsToOptions params.rule // {
|
rule = paramsToOptions params.rule // {
|
||||||
enable = mkEnableOption
|
enable = mkEnableOption
|
||||||
(lib.mdDoc ("the Thanos ruler service which evaluates Prometheus rules against" +
|
(lib.mdDoc ("the Thanos ruler service which evaluates Prometheus rules against" +
|
||||||
|
@ -768,6 +781,18 @@ in {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.query-frontend.enable {
|
||||||
|
systemd.services.thanos-query-frontend = {
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
serviceConfig = {
|
||||||
|
DynamicUser = true;
|
||||||
|
Restart = "always";
|
||||||
|
ExecStart = thanos "query-frontend";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
(mkIf cfg.rule.enable (mkMerge [
|
(mkIf cfg.rule.enable (mkMerge [
|
||||||
(assertRelativeStateDir "rule")
|
(assertRelativeStateDir "rule")
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@ let
|
||||||
queryPort = 9090;
|
queryPort = 9090;
|
||||||
minioPort = 9000;
|
minioPort = 9000;
|
||||||
pushgwPort = 9091;
|
pushgwPort = 9091;
|
||||||
|
frontPort = 9092;
|
||||||
|
|
||||||
s3 = {
|
s3 = {
|
||||||
accessKey = "BKIKJAA5BMMU2RHO6IBB";
|
accessKey = "BKIKJAA5BMMU2RHO6IBB";
|
||||||
|
@ -156,6 +157,11 @@ in import ./make-test-python.nix {
|
||||||
"prometheus:${toString grpcPort}"
|
"prometheus:${toString grpcPort}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
services.thanos.query-frontend = {
|
||||||
|
enable = true;
|
||||||
|
http-address = "0.0.0.0:${toString frontPort}";
|
||||||
|
query-frontend.downstream-url = "http://127.0.0.1:${toString queryPort}";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
store = { pkgs, ... }: {
|
store = { pkgs, ... }: {
|
||||||
|
@ -262,6 +268,10 @@ in import ./make-test-python.nix {
|
||||||
query.wait_for_unit("thanos-query.service")
|
query.wait_for_unit("thanos-query.service")
|
||||||
wait_for_metric(query)
|
wait_for_metric(query)
|
||||||
|
|
||||||
|
# Test Thanos query frontend service
|
||||||
|
query.wait_for_unit("thanos-query-frontend.service")
|
||||||
|
query.succeed("curl -sS http://localhost:${toString frontPort}/-/healthy")
|
||||||
|
|
||||||
# Test if the Thanos sidecar has correctly uploaded its TSDB to S3, if the
|
# Test if the Thanos sidecar has correctly uploaded its TSDB to S3, if the
|
||||||
# Thanos storage service has correctly downloaded it from S3 and if the Thanos
|
# Thanos storage service has correctly downloaded it from S3 and if the Thanos
|
||||||
# query service running on $store can correctly retrieve the metric:
|
# query service running on $store can correctly retrieve the metric:
|
||||||
|
|
Loading…
Reference in a new issue