@@ -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+}