about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix
blob: bc67fe59b3b8341785e85767fe414df83ebbc0f5 (plain) (blame)
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
{ config, lib, pkgs, options }:

with lib;

let
  cfg = config.services.prometheus.exporters.artifactory;
in
{
  port = 9531;
  extraOpts = {
    scrapeUri = mkOption {
      type = types.str;
      default = "http://localhost:8081/artifactory";
      description = lib.mdDoc ''
        URI on which to scrape JFrog Artifactory.
      '';
    };

    artiUsername = mkOption {
      type = types.str;
      description = lib.mdDoc ''
        Username for authentication against JFrog Artifactory API.
      '';
    };

    artiPassword = mkOption {
      type = types.str;
      default = "";
      description = lib.mdDoc ''
        Password for authentication against JFrog Artifactory API.
        One of the password or access token needs to be set.
      '';
    };

    artiAccessToken = mkOption {
      type = types.str;
      default = "";
      description = lib.mdDoc ''
        Access token for authentication against JFrog Artifactory API.
        One of the password or access token needs to be set.
      '';
    };
  };
  serviceOpts = {
    serviceConfig = {
      ExecStart = ''
        ${pkgs.prometheus-artifactory-exporter}/bin/artifactory_exporter \
          --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
          --artifactory.scrape-uri ${cfg.scrapeUri} \
          ${concatStringsSep " \\\n  " cfg.extraFlags}
      '';
      Environment = [
        "ARTI_USERNAME=${cfg.artiUsername}"
        "ARTI_PASSWORD=${cfg.artiPassword}"
        "ARTI_ACCESS_TOKEN=${cfg.artiAccessToken}"
      ];
    };
  };
}