summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/co/cortex-tools/package.nix
blob: 84ae824e5c5111a3e6ff67f8842faeaaec0e692a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  gitUpdater,
  versionCheckHook,
  installShellFiles,
  stdenv,
  nix-update-script,
}:
buildGoModule (finalAttrs: {
  pname = "cortex-tools";
  version = "0.11.3";

  src = fetchFromGitHub {
    owner = "grafana-cold-storage";
    repo = "cortex-tools";
    tag = "v${finalAttrs.version}";
    hash = "sha256-+GWUC+lnCn5Nw2WytSvW/UsIMmMelCCsnKdBCHuue24=";
  };

  vendorHash = null;

  subPackages = [
    "cmd/benchtool"
    "cmd/cortextool"
    "cmd/e2ealerting"
    "cmd/logtool"
  ];

  env.CGO_ENABLED = 0;

  ldflags = [
    "-X github.com/grafana-cold-storage/cortex-tools/pkg/version.Version=${finalAttrs.src.tag}"
    "-s"
    "-w"
  ];

  doCheck = true;

  passthru.updateScript = nix-update-script { };

  nativeBuildInputs = [ installShellFiles ];

  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
    installShellCompletion --cmd cortextool \
      --bash <($out/bin/cortextool --completion-script-bash) \
      --zsh <($out/bin/cortextool --completion-script-zsh)

    $out/bin/cortextool --help-man > cortextool.1
    installManPage cortextool.1
  '';

  doInstallCheck = true;

  nativeInstallCheckInputs = [
    versionCheckHook
  ];

  versionCheckProgramArg = "version";

  meta = {
    changelog = "https://github.com/grafana-cold-storage/cortex-tools/releases/tag/${finalAttrs.src.tag}";
    description = "Tools used for interacting with Cortex, a Prometheus-compatible server";
    longDescription = ''
      Tools used for interacting with Cortex, a horizontally scalable, highly available, multi-tenant, long term Prometheus server:

      - benchtool: A powerful YAML driven tool for benchmarking Cortex write and query API.
      - cortextool: Interacts with user-facing Cortex APIs and backend storage components.
      - logtool: Tool which parses Cortex query-frontend logs and formats them for easy analysis.
      - e2ealerting: Tool that helps measure how long an alert takes from scrape of sample to Alertmanager notification delivery.
    '';
    homepage = "https://github.com/grafana-cold-storage/cortex-tools";
    license = lib.licenses.asl20;
    platforms = lib.platforms.linux ++ lib.platforms.windows ++ lib.platforms.darwin;
    maintainers = with lib.maintainers; [ videl ];
    mainProgram = "cortextool";
  };
})