Merge pull request #260089 from anthonyroussel/thanos_0_32_4

authored by Artturi and committed by GitHub b736459b d08965ed

+136 -66
+95 -50
nixos/modules/services/monitoring/thanos.nix
··· 1 1 { config, lib, pkgs, ... }: 2 2 3 - with lib; 3 + let 4 + inherit (lib) 5 + collect 6 + concatLists 7 + concatStringsSep 8 + flip 9 + getAttrFromPath 10 + hasPrefix 11 + isList 12 + length 13 + literalExpression 14 + literalMD 15 + mapAttrsRecursiveCond 16 + mapAttrsToList 17 + mdDoc 18 + mkEnableOption 19 + mkIf 20 + mkMerge 21 + mkOption 22 + mkPackageOptionMD 23 + optional 24 + optionalAttrs 25 + optionalString 26 + types 27 + ; 4 28 5 - let 6 29 cfg = config.services.thanos; 7 30 8 31 nullOpt = type: description: mkOption { 9 32 type = types.nullOr type; 10 33 default = null; 11 - description = lib.mdDoc description; 34 + description = mdDoc description; 12 35 }; 13 36 14 37 optionToArgs = opt: v : optional (v != null) ''--${opt}="${toString v}"''; ··· 32 55 option = mkOption { 33 56 type = types.bool; 34 57 default = false; 35 - description = lib.mdDoc description; 58 + description = mdDoc description; 36 59 }; 37 60 }; 38 61 ··· 41 64 option = mkOption { 42 65 type = types.listOf types.str; 43 66 default = []; 44 - description = lib.mdDoc description; 67 + description = mdDoc description; 45 68 }; 46 69 }; 47 70 ··· 50 73 option = mkOption { 51 74 type = types.attrsOf types.str; 52 75 default = {}; 53 - description = lib.mdDoc description; 76 + description = mdDoc description; 54 77 }; 55 78 }; 56 79 ··· 59 82 option = mkOption { 60 83 type = types.str; 61 84 inherit default; 62 - description = lib.mdDoc description; 85 + description = mdDoc description; 63 86 }; 64 87 }; 65 88 ··· 86 109 defaultText = literalMD '' 87 110 calculated from `config.services.thanos.${cmd}` 88 111 ''; 89 - description = lib.mdDoc '' 112 + description = mdDoc '' 90 113 Arguments to the `thanos ${cmd}` command. 91 114 92 115 Defaults to a list of arguments formed by converting the structured ··· 127 150 if config.services.thanos.<cmd>.tracing.config == null then null 128 151 else toString (toYAML "tracing.yaml" config.services.thanos.<cmd>.tracing.config); 129 152 ''; 130 - description = lib.mdDoc '' 153 + description = mdDoc '' 131 154 Path to YAML file that contains tracing configuration. 132 155 133 - See format details: <https://thanos.io/tracing.md/#configuration> 156 + See format details: <https://thanos.io/tip/thanos/tracing.md/#configuration> 134 157 ''; 135 158 }; 136 159 }; ··· 147 170 148 171 If {option}`tracing.config-file` is set this option has no effect. 149 172 150 - See format details: <https://thanos.io/tracing.md/#configuration> 173 + See format details: <https://thanos.io/tip/thanos/tracing.md/#configuration> 151 174 ''; 152 175 }; 153 176 }; ··· 192 215 if config.services.thanos.<cmd>.objstore.config == null then null 193 216 else toString (toYAML "objstore.yaml" config.services.thanos.<cmd>.objstore.config); 194 217 ''; 195 - description = lib.mdDoc '' 218 + description = mdDoc '' 196 219 Path to YAML file that contains object store configuration. 197 220 198 - See format details: <https://thanos.io/storage.md/#configuration> 221 + See format details: <https://thanos.io/tip/thanos/storage.md/#configuring-access-to-object-storage> 199 222 ''; 200 223 }; 201 224 }; ··· 212 235 213 236 If {option}`objstore.config-file` is set this option has no effect. 214 237 215 - See format details: <https://thanos.io/storage.md/#configuration> 238 + See format details: <https://thanos.io/tip/thanos/storage.md/#configuring-access-to-object-storage> 216 239 ''; 217 240 }; 218 241 }; ··· 231 254 type = types.str; 232 255 default = "/var/lib/${config.services.prometheus.stateDir}/data"; 233 256 defaultText = literalExpression ''"/var/lib/''${config.services.prometheus.stateDir}/data"''; 234 - description = lib.mdDoc '' 257 + description = mdDoc '' 235 258 Data directory of TSDB. 236 259 ''; 237 260 }; ··· 266 289 Maximum size of concurrently allocatable bytes for chunks. 267 290 ''; 268 291 269 - store.grpc.series-sample-limit = mkParamDef types.int 0 '' 270 - Maximum amount of samples returned via a single Series call. 292 + store.limits.request-samples = mkParamDef types.int 0 '' 293 + The maximum samples allowed for a single Series request. 294 + The Series call fails if this limit is exceeded. 271 295 272 296 `0` means no limit. 273 297 274 - NOTE: for efficiency we take 120 as the number of samples in chunk (it 275 - cannot be bigger than that), so the actual number of samples might be 276 - lower, even though the maximum could be hit. 298 + NOTE: For efficiency the limit is internally implemented as 'chunks limit' 299 + considering each chunk contains a maximum of 120 samples. 277 300 ''; 278 301 279 302 store.grpc.series-max-concurrency = mkParamDef types.int 20 '' ··· 371 394 Maximum number of queries processed concurrently by query node. 372 395 ''; 373 396 374 - query.replica-label = mkParam types.str '' 375 - Label to treat as a replica indicator along which data is 397 + query.replica-labels = mkAttrsParam "query.replica-label" '' 398 + Labels to treat as a replica indicator along which data is 399 + 376 400 deduplicated. 377 401 378 402 Still you will be able to query without deduplication using 379 - `dedup=false` parameter. 403 + 'dedup=false' parameter. Data includes time series, recording 404 + rules, and alerting rules. 380 405 ''; 381 406 382 407 selector-labels = mkAttrsParam "selector-label" '' 383 408 Query selector labels that will be exposed in info endpoint. 384 409 ''; 385 410 386 - store.addresses = mkListParam "store" '' 387 - Addresses of statically configured store API servers. 411 + endpoints = mkListParam "endpoint" '' 412 + Addresses of statically configured Thanos API servers (repeatable). 388 413 389 - The scheme may be prefixed with `dns+` or 390 - `dnssrv+` to detect store API servers through 391 - respective DNS lookups. 414 + The scheme may be prefixed with 'dns+' or 'dnssrv+' to detect 415 + Thanos API servers through respective DNS lookups. 392 416 ''; 393 417 394 418 store.sd-files = mkListParam "store.sd-files" '' ··· 430 454 ''; 431 455 }; 432 456 457 + query-frontend = params.common cfg.query-frontend // { 458 + query-frontend.downstream-url = mkParamDef types.str "http://localhost:9090" '' 459 + URL of downstream Prometheus Query compatible API. 460 + ''; 461 + }; 462 + 433 463 rule = params.common cfg.rule // params.objstore cfg.rule // { 434 464 435 465 labels = mkAttrsParam "label" '' ··· 447 477 Rule files that should be used by rule manager. Can be in glob format. 448 478 ''; 449 479 450 - eval-interval = mkParamDef types.str "30s" '' 480 + eval-interval = mkParamDef types.str "1m" '' 451 481 The default evaluation interval to use. 452 482 ''; 453 483 ··· 597 627 to render all samples for a human eye anyway 598 628 ''; 599 629 600 - block-sync-concurrency = mkParamDef types.int 20 '' 601 - Number of goroutines to use when syncing block metadata from object storage. 602 - ''; 603 - 604 630 compact.concurrency = mkParamDef types.int 1 '' 605 631 Number of goroutines to use when compacting groups. 606 632 ''; ··· 625 651 Data directory relative to `/var/lib` of TSDB. 626 652 ''; 627 653 628 - labels = mkAttrsParam "labels" '' 654 + labels = mkAttrsParam "label" '' 629 655 External labels to announce. 630 656 631 657 This flag will be removed in the future when handling multiple tsdb ··· 656 682 657 683 options.services.thanos = { 658 684 659 - package = mkOption { 660 - type = types.package; 661 - default = pkgs.thanos; 662 - defaultText = literalExpression "pkgs.thanos"; 663 - description = lib.mdDoc '' 664 - The thanos package that should be used. 665 - ''; 666 - }; 685 + package = mkPackageOptionMD pkgs "thanos" {}; 667 686 668 687 sidecar = paramsToOptions params.sidecar // { 669 688 enable = mkEnableOption 670 - (lib.mdDoc "the Thanos sidecar for Prometheus server"); 689 + (mdDoc "the Thanos sidecar for Prometheus server"); 671 690 arguments = mkArgumentsOption "sidecar"; 672 691 }; 673 692 674 693 store = paramsToOptions params.store // { 675 694 enable = mkEnableOption 676 - (lib.mdDoc "the Thanos store node giving access to blocks in a bucket provider."); 695 + (mdDoc "the Thanos store node giving access to blocks in a bucket provider."); 677 696 arguments = mkArgumentsOption "store"; 678 697 }; 679 698 680 699 query = paramsToOptions params.query // { 681 700 enable = mkEnableOption 682 - (lib.mdDoc ("the Thanos query node exposing PromQL enabled Query API " + 701 + (mdDoc ("the Thanos query node exposing PromQL enabled Query API " + 683 702 "with data retrieved from multiple store nodes")); 684 703 arguments = mkArgumentsOption "query"; 685 704 }; 686 705 706 + query-frontend = paramsToOptions params.query-frontend // { 707 + enable = mkEnableOption 708 + (mdDoc ("the Thanos query frontend implements a service deployed in front of queriers to 709 + improve query parallelization and caching.")); 710 + arguments = mkArgumentsOption "query-frontend"; 711 + }; 712 + 687 713 rule = paramsToOptions params.rule // { 688 714 enable = mkEnableOption 689 - (lib.mdDoc ("the Thanos ruler service which evaluates Prometheus rules against" + 715 + (mdDoc ("the Thanos ruler service which evaluates Prometheus rules against" + 690 716 " given Query nodes, exposing Store API and storing old blocks in bucket")); 691 717 arguments = mkArgumentsOption "rule"; 692 718 }; 693 719 694 720 compact = paramsToOptions params.compact // { 695 721 enable = mkEnableOption 696 - (lib.mdDoc "the Thanos compactor which continuously compacts blocks in an object store bucket"); 722 + (mdDoc "the Thanos compactor which continuously compacts blocks in an object store bucket"); 697 723 arguments = mkArgumentsOption "compact"; 698 724 }; 699 725 700 726 downsample = paramsToOptions params.downsample // { 701 727 enable = mkEnableOption 702 - (lib.mdDoc "the Thanos downsampler which continuously downsamples blocks in an object store bucket"); 728 + (mdDoc "the Thanos downsampler which continuously downsamples blocks in an object store bucket"); 703 729 arguments = mkArgumentsOption "downsample"; 704 730 }; 705 731 706 732 receive = paramsToOptions params.receive // { 707 733 enable = mkEnableOption 708 - (lib.mdDoc ("the Thanos receiver which accept Prometheus remote write API requests " + 709 - "and write to local tsdb (EXPERIMENTAL, this may change drastically without notice)")); 734 + (mdDoc ("the Thanos receiver which accept Prometheus remote write API requests and write to local tsdb")); 710 735 arguments = mkArgumentsOption "receive"; 711 736 }; 712 737 }; ··· 736 761 User = "prometheus"; 737 762 Restart = "always"; 738 763 ExecStart = thanos "sidecar"; 764 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 739 765 }; 740 766 }; 741 767 }) ··· 751 777 StateDirectory = cfg.store.stateDir; 752 778 Restart = "always"; 753 779 ExecStart = thanos "store"; 780 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 754 781 }; 755 782 }; 756 783 } ··· 764 791 DynamicUser = true; 765 792 Restart = "always"; 766 793 ExecStart = thanos "query"; 794 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 795 + }; 796 + }; 797 + }) 798 + 799 + (mkIf cfg.query-frontend.enable { 800 + systemd.services.thanos-query-frontend = { 801 + wantedBy = [ "multi-user.target" ]; 802 + after = [ "network.target" ]; 803 + serviceConfig = { 804 + DynamicUser = true; 805 + Restart = "always"; 806 + ExecStart = thanos "query-frontend"; 807 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 767 808 }; 768 809 }; 769 810 }) ··· 779 820 StateDirectory = cfg.rule.stateDir; 780 821 Restart = "always"; 781 822 ExecStart = thanos "rule"; 823 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 782 824 }; 783 825 }; 784 826 } ··· 797 839 DynamicUser = true; 798 840 StateDirectory = cfg.compact.stateDir; 799 841 ExecStart = thanos "compact"; 842 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 800 843 }; 801 844 } // optionalAttrs (!wait) { inherit (cfg.compact) startAt; }; 802 845 } ··· 813 856 StateDirectory = cfg.downsample.stateDir; 814 857 Restart = "always"; 815 858 ExecStart = thanos "downsample"; 859 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 816 860 }; 817 861 }; 818 862 } ··· 829 873 StateDirectory = cfg.receive.stateDir; 830 874 Restart = "always"; 831 875 ExecStart = thanos "receive"; 876 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 832 877 }; 833 878 }; 834 879 }
+12 -2
nixos/tests/prometheus.nix
··· 3 3 queryPort = 9090; 4 4 minioPort = 9000; 5 5 pushgwPort = 9091; 6 + frontPort = 9092; 6 7 7 8 s3 = { 8 9 accessKey = "BKIKJAA5BMMU2RHO6IBB"; ··· 152 153 services.thanos.query = { 153 154 enable = true; 154 155 http-address = "0.0.0.0:${toString queryPort}"; 155 - store.addresses = [ 156 + endpoints = [ 156 157 "prometheus:${toString grpcPort}" 157 158 ]; 159 + }; 160 + services.thanos.query-frontend = { 161 + enable = true; 162 + http-address = "0.0.0.0:${toString frontPort}"; 163 + query-frontend.downstream-url = "http://127.0.0.1:${toString queryPort}"; 158 164 }; 159 165 }; 160 166 ··· 178 184 services.thanos.query = { 179 185 enable = true; 180 186 http-address = "0.0.0.0:${toString queryPort}"; 181 - store.addresses = [ 187 + endpoints = [ 182 188 "localhost:${toString grpcPort}" 183 189 ]; 184 190 }; ··· 261 267 # Test if the Thanos query service can correctly retrieve the metric that was send above. 262 268 query.wait_for_unit("thanos-query.service") 263 269 wait_for_metric(query) 270 + 271 + # Test Thanos query frontend service 272 + query.wait_for_unit("thanos-query-frontend.service") 273 + query.succeed("curl -sS http://localhost:${toString frontPort}/-/healthy") 264 274 265 275 # Test if the Thanos sidecar has correctly uploaded its TSDB to S3, if the 266 276 # Thanos storage service has correctly downloaded it from S3 and if the Thanos
+29 -14
pkgs/servers/monitoring/thanos/default.nix
··· 1 - { lib, buildGoModule, fetchFromGitHub, fetchpatch }: 1 + { lib 2 + , buildGoModule 3 + , fetchFromGitHub 4 + , go 5 + , nix-update-script 6 + , nixosTests 7 + , testers 8 + , thanos 9 + }: 10 + 2 11 buildGoModule rec { 3 12 pname = "thanos"; 4 - version = "0.31.0"; 13 + version = "0.32.5"; 5 14 6 15 src = fetchFromGitHub { 7 - rev = "v${version}"; 8 16 owner = "thanos-io"; 9 17 repo = "thanos"; 10 - sha256 = "sha256-EJZGc4thu0WhVSSRolIRYg39S81Cgm+JHwpW5eE7mDc="; 18 + rev = "refs/tags/v${version}"; 19 + hash = "sha256-A4bDCyvctHmDBYzvWpeEO4u6KhoICN7BbRQK4aZCbIA="; 11 20 }; 12 21 13 - patches = [ 14 - # https://github.com/thanos-io/thanos/pull/6126 15 - (fetchpatch { 16 - url = "https://github.com/thanos-io/thanos/commit/a4c218bd690259fc0c78fe67e0739bd33d38541e.patch"; 17 - hash = "sha256-Hxc1s5IXAyw01/o4JvOXuyYuOFy0+cBUv3OkRv4DCXs="; 18 - }) 19 - ]; 20 - 21 - vendorHash = "sha256-8+MUMux6v/O2syVyTx758yUBfJkertzibz6yFB05nWk="; 22 + vendorHash = "sha256-ZjkMvbWq96Rte9WoxAWzeouVA/6mBqanvY9yHr9F5MM="; 22 23 23 24 doCheck = true; 24 25 ··· 30 31 "-X ${t}.Branch=unknown" 31 32 "-X ${t}.BuildUser=nix@nixpkgs" 32 33 "-X ${t}.BuildDate=unknown" 34 + "-X ${t}.GoVersion=${lib.getVersion go}" 33 35 ]; 34 36 37 + passthru = { 38 + updateScript = nix-update-script { }; 39 + tests = { 40 + inherit (nixosTests) prometheus; 41 + version = testers.testVersion { 42 + command = "thanos --version"; 43 + package = thanos; 44 + }; 45 + }; 46 + }; 47 + 35 48 meta = with lib; { 36 49 description = "Highly available Prometheus setup with long term storage capabilities"; 37 50 homepage = "https://github.com/thanos-io/thanos"; 51 + changelog = "https://github.com/thanos-io/thanos/releases/tag/v${version}"; 38 52 license = licenses.asl20; 39 - maintainers = with maintainers; [ basvandijk ]; 53 + mainProgram = "thanos"; 54 + maintainers = with maintainers; [ basvandijk anthonyroussel ]; 40 55 }; 41 56 }