1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 gitUpdater,
6 versionCheckHook,
7 installShellFiles,
8 stdenv,
9 nix-update-script,
10}:
11buildGoModule (finalAttrs: {
12 pname = "cortex-tools";
13 version = "0.11.3";
14
15 src = fetchFromGitHub {
16 owner = "grafana";
17 repo = "cortex-tools";
18 tag = "v${finalAttrs.version}";
19 hash = "sha256-+GWUC+lnCn5Nw2WytSvW/UsIMmMelCCsnKdBCHuue24=";
20 };
21
22 vendorHash = null;
23
24 subPackages = [
25 "cmd/benchtool"
26 "cmd/cortextool"
27 "cmd/e2ealerting"
28 "cmd/logtool"
29 ];
30
31 env.CGO_ENABLED = 0;
32
33 ldflags = [
34 "-X github.com/grafana/cortex-tools/pkg/version.Version=${finalAttrs.src.tag}"
35 "-s"
36 "-w"
37 ];
38
39 doCheck = true;
40
41 passthru.updateScript = nix-update-script { };
42
43 nativeBuildInputs = [ installShellFiles ];
44
45 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
46 installShellCompletion --cmd cortextool \
47 --bash <($out/bin/cortextool --completion-script-bash) \
48 --zsh <($out/bin/cortextool --completion-script-zsh)
49
50 $out/bin/cortextool --help-man > cortextool.1
51 installManPage cortextool.1
52 '';
53
54 doInstallCheck = true;
55
56 nativeInstallCheckInputs = [
57 versionCheckHook
58 ];
59
60 versionCheckProgramArg = "version";
61
62 meta = {
63 changelog = "https://github.com/grafana/cortex-tools/releases/tag/${finalAttrs.src.tag}";
64 description = "Tools used for interacting with Cortex, a Prometheus-compatible server";
65 longDescription = ''
66 Tools used for interacting with Cortex, a horizontally scalable, highly available, multi-tenant, long term Prometheus server:
67
68 - benchtool: A powerful YAML driven tool for benchmarking Cortex write and query API.
69 - cortextool: Interacts with user-facing Cortex APIs and backend storage components.
70 - logtool: Tool which parses Cortex query-frontend logs and formats them for easy analysis.
71 - e2ealerting: Tool that helps measure how long an alert takes from scrape of sample to Alertmanager notification delivery.
72 '';
73 homepage = "https://github.com/grafana/cortex-tools";
74 license = lib.licenses.asl20;
75 platforms = lib.platforms.linux ++ lib.platforms.windows ++ lib.platforms.darwin;
76 maintainers = with lib.maintainers; [ videl ];
77 mainProgram = "cortextool";
78 };
79})