summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorWilliButz <WilliButz@users.noreply.github.com>2021-03-11 18:44:03 +0100
committerGitHub <noreply@github.com>2021-03-11 18:44:03 +0100
commit902a479225855ed215da6ca2aa50181cc9a9344b (patch)
tree6acd0ae9509f772c3c0f8ddf84a307c3d57a4d23 /nixos
parent90e466041a4546bae74b2b27f390f8b4bc854a02 (diff)
parent458fafa8fc9c83d9f0648e2758e8e0ddd45bc5ad (diff)
Merge pull request #111364 from lbpdt/feature/prometheus-artifactory-exporter
nixos/prometheus-exporters/artifactory: init at 1.9.0
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters.nix1
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix59
-rw-r--r--nixos/tests/prometheus-exporters.nix15
3 files changed, 75 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix
index 940f28189371..34cb0740cef2 100644
--- a/nixos/modules/services/monitoring/prometheus/exporters.nix
+++ b/nixos/modules/services/monitoring/prometheus/exporters.nix
@@ -22,6 +22,7 @@ let
exporterOpts = genAttrs [
"apcupsd"
+ "artifactory"
"bind"
"bird"
"blackbox"
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix b/nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix
new file mode 100644
index 000000000000..2adcecc728bd
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix
@@ -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}"
+ ];
+ };
+ };
+}
diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix
index 89d17c9de8c0..161762de7236 100644
--- a/nixos/tests/prometheus-exporters.nix
+++ b/nixos/tests/prometheus-exporters.nix
@@ -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 = {
exporterConfig = {
enable = true;