git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #111364 from lbpdt/feature/prometheus-artifactory-exporter

nixos/prometheus-exporters/artifactory: init at 1.9.0

commit902a479225855ed215da6ca2aa50181cc9a9344b authorWilliButz <WilliButz@users.noreply.github.com> dateThu 11 Mar 2021, 18:44 (6 years ago) parent90e4660458fafa
5 files changed+112
nixos/modules/services/monitoring/prometheus/exporters.nix+1 nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix+59 nixos/tests/prometheus-exporters.nix+15 pkgs/servers/monitoring/prometheus/artifactory-exporter.nix+36 pkgs/top-level/all-packages.nix+1
nixos/modules/services/monitoring/prometheus/exporters.nix+1
@@ -22,6 +22,7 @@ let
2222
2323 exporterOpts = genAttrs [
2424 "apcupsd"
25+ "artifactory"
2526 "bind"
2627 "bird"
2728 "blackbox"
nixos/modules/services/monitoring/prometheus/exporters/artifactory.nixnew file+59
@@ -0,0 +1,59 @@
1+{ config, lib, pkgs, options }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.prometheus.exporters.artifactory;
7+in
8+{
9+ port = 9531;
10+ extraOpts = {
11+ scrapeUri = mkOption {
12+ type = types.str;
13+ default = "http://localhost:8081/artifactory";
14+ description = ''
15+ URI on which to scrape JFrog Artifactory.
16+ '';
17+ };
18+
19+ artiUsername = mkOption {
20+ type = types.str;
21+ description = ''
22+ Username for authentication against JFrog Artifactory API.
23+ '';
24+ };
25+
26+ artiPassword = mkOption {
27+ type = types.str;
28+ default = "";
29+ description = ''
30+ Password for authentication against JFrog Artifactory API.
31+ One of the password or access token needs to be set.
32+ '';
33+ };
34+
35+ artiAccessToken = mkOption {
36+ type = types.str;
37+ default = "";
38+ description = ''
39+ Access token for authentication against JFrog Artifactory API.
40+ One of the password or access token needs to be set.
41+ '';
42+ };
43+ };
44+ serviceOpts = {
45+ serviceConfig = {
46+ ExecStart = ''
47+ ${pkgs.prometheus-artifactory-exporter}/bin/artifactory_exporter \
48+ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
49+ --artifactory.scrape-uri ${cfg.scrapeUri} \
50+ ${concatStringsSep " \\\n " cfg.extraFlags}
51+ '';
52+ Environment = [
53+ "ARTI_USERNAME=${cfg.artiUsername}"
54+ "ARTI_PASSWORD=${cfg.artiPassword}"
55+ "ARTI_ACCESS_TOKEN=${cfg.artiAccessToken}"
56+ ];
57+ };
58+ };
59+}
nixos/tests/prometheus-exporters.nix+15
@@ -75,6 +75,21 @@ let
7575 '';
7676 };
7777
78+ artifactory = {
79+ exporterConfig = {
80+ enable = true;
81+ artiUsername = "artifactory-username";
82+ artiPassword = "artifactory-password";
83+ };
84+ exporterTest = ''
85+ wait_for_unit("prometheus-artifactory-exporter.service")
86+ wait_for_open_port(9531)
87+ succeed(
88+ "curl -sSf http://localhost:9531/metrics | grep -q 'artifactory_up'"
89+ )
90+ '';
91+ };
92+
7893 bind = {
7994 exporterConfig = {
8095 enable = true;
pkgs/servers/monitoring/prometheus/artifactory-exporter.nixnew file+36
@@ -0,0 +1,36 @@
1+{ lib, buildGoModule, fetchFromGitHub, nixosTests }:
2+
3+buildGoModule rec {
4+ pname = "artifactory_exporter";
5+ version = "1.9.0";
6+ rev = "v${version}";
7+
8+ src = fetchFromGitHub {
9+ owner = "peimanja";
10+ repo = pname;
11+ rev = rev;
12+ sha256 = "1zmkajg48i40jm624p2h03bwg7w28682yfcgk42ig3d50p8xwqc3";
13+ };
14+
15+ vendorSha256 = "1594bpfwhbjgayf4aacs7rfjxm4cnqz8iak8kpm1xzsm1cx1il17";
16+
17+ subPackages = [ "." ];
18+
19+ buildFlagsArray = ''
20+ -ldflags=
21+ -s -w
22+ -X github.com/prometheus/common/version.Version=${version}
23+ -X github.com/prometheus/common/version.Revision=${rev}
24+ -X github.com/prometheus/common/version.Branch=master
25+ -X github.com/prometheus/common/version.BuildDate=19700101-00:00:00
26+ '';
27+
28+ passthru.tests = { inherit (nixosTests.prometheus-exporters) artifactory; };
29+
30+ meta = with lib; {
31+ description = "JFrog Artifactory Prometheus Exporter";
32+ homepage = "https://github.com/peimanja/artifactory_exporter";
33+ license = licenses.asl20;
34+ maintainers = with maintainers; [ lbpdt ];
35+ };
36+}
pkgs/top-level/all-packages.nix+1
@@ -18580,6 +18580,7 @@ in
1858018580 };
1858118581 prometheus-alertmanager = callPackage ../servers/monitoring/prometheus/alertmanager.nix { };
1858218582 prometheus-apcupsd-exporter = callPackage ../servers/monitoring/prometheus/apcupsd-exporter.nix { };
18583+ prometheus-artifactory-exporter = callPackage ../servers/monitoring/prometheus/artifactory-exporter.nix { };
1858318584 prometheus-aws-s3-exporter = callPackage ../servers/monitoring/prometheus/aws-s3-exporter.nix { };
1858418585 prometheus-bind-exporter = callPackage ../servers/monitoring/prometheus/bind-exporter.nix { };
1858518586 prometheus-bird-exporter = callPackage ../servers/monitoring/prometheus/bird-exporter.nix { };