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