Merge pull request #111364 from lbpdt/feature/prometheus-artifactory-exporter

nixos/prometheus-exporters/artifactory: init at 1.9.0
This commit is contained in:
WilliButz 2021-03-11 18:44:03 +01:00 committed by GitHub
commit 902a479225
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 112 additions and 0 deletions

View file

@ -22,6 +22,7 @@ let
exporterOpts = genAttrs [ exporterOpts = genAttrs [
"apcupsd" "apcupsd"
"artifactory"
"bind" "bind"
"bird" "bird"
"blackbox" "blackbox"

View file

@ -0,0 +1,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 = ''
URI on which to scrape JFrog Artifactory.
'';
};
artiUsername = mkOption {
type = types.str;
description = ''
Username for authentication against JFrog Artifactory API.
'';
};
artiPassword = mkOption {
type = types.str;
default = "";
description = ''
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 = ''
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}"
];
};
};
}

View file

@ -75,6 +75,21 @@ let
''; '';
}; };
artifactory = {
exporterConfig = {
enable = true;
artiUsername = "artifactory-username";
artiPassword = "artifactory-password";
};
exporterTest = ''
wait_for_unit("prometheus-artifactory-exporter.service")
wait_for_open_port(9531)
succeed(
"curl -sSf http://localhost:9531/metrics | grep -q 'artifactory_up'"
)
'';
};
bind = { bind = {
exporterConfig = { exporterConfig = {
enable = true; enable = true;

View file

@ -0,0 +1,36 @@
{ lib, buildGoModule, fetchFromGitHub, nixosTests }:
buildGoModule rec {
pname = "artifactory_exporter";
version = "1.9.0";
rev = "v${version}";
src = fetchFromGitHub {
owner = "peimanja";
repo = pname;
rev = rev;
sha256 = "1zmkajg48i40jm624p2h03bwg7w28682yfcgk42ig3d50p8xwqc3";
};
vendorSha256 = "1594bpfwhbjgayf4aacs7rfjxm4cnqz8iak8kpm1xzsm1cx1il17";
subPackages = [ "." ];
buildFlagsArray = ''
-ldflags=
-s -w
-X github.com/prometheus/common/version.Version=${version}
-X github.com/prometheus/common/version.Revision=${rev}
-X github.com/prometheus/common/version.Branch=master
-X github.com/prometheus/common/version.BuildDate=19700101-00:00:00
'';
passthru.tests = { inherit (nixosTests.prometheus-exporters) artifactory; };
meta = with lib; {
description = "JFrog Artifactory Prometheus Exporter";
homepage = "https://github.com/peimanja/artifactory_exporter";
license = licenses.asl20;
maintainers = with maintainers; [ lbpdt ];
};
}

View file

@ -18580,6 +18580,7 @@ in
}; };
prometheus-alertmanager = callPackage ../servers/monitoring/prometheus/alertmanager.nix { }; prometheus-alertmanager = callPackage ../servers/monitoring/prometheus/alertmanager.nix { };
prometheus-apcupsd-exporter = callPackage ../servers/monitoring/prometheus/apcupsd-exporter.nix { }; prometheus-apcupsd-exporter = callPackage ../servers/monitoring/prometheus/apcupsd-exporter.nix { };
prometheus-artifactory-exporter = callPackage ../servers/monitoring/prometheus/artifactory-exporter.nix { };
prometheus-aws-s3-exporter = callPackage ../servers/monitoring/prometheus/aws-s3-exporter.nix { }; prometheus-aws-s3-exporter = callPackage ../servers/monitoring/prometheus/aws-s3-exporter.nix { };
prometheus-bind-exporter = callPackage ../servers/monitoring/prometheus/bind-exporter.nix { }; prometheus-bind-exporter = callPackage ../servers/monitoring/prometheus/bind-exporter.nix { };
prometheus-bird-exporter = callPackage ../servers/monitoring/prometheus/bird-exporter.nix { }; prometheus-bird-exporter = callPackage ../servers/monitoring/prometheus/bird-exporter.nix { };