From aad88ddf5bdeb25e586d4de3ef1a639d4c95f3cf Mon Sep 17 00:00:00 2001 From: Pascal Bach Date: Sun, 8 Oct 2017 12:07:05 +0200 Subject: [PATCH] prometheus-minio-exporter service: init version --- nixos/modules/module-list.nix | 1 + .../monitoring/prometheus/minio-exporter.nix | 107 ++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 nixos/modules/services/monitoring/prometheus/minio-exporter.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 8ac7e5b52d69..ee796242c1a2 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -375,6 +375,7 @@ ./services/monitoring/prometheus/collectd-exporter.nix ./services/monitoring/prometheus/fritzbox-exporter.nix ./services/monitoring/prometheus/json-exporter.nix + ./services/monitoring/prometheus/minio-exporter.nix ./services/monitoring/prometheus/nginx-exporter.nix ./services/monitoring/prometheus/node-exporter.nix ./services/monitoring/prometheus/snmp-exporter.nix diff --git a/nixos/modules/services/monitoring/prometheus/minio-exporter.nix b/nixos/modules/services/monitoring/prometheus/minio-exporter.nix new file mode 100644 index 000000000000..4b6c96d96737 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/minio-exporter.nix @@ -0,0 +1,107 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.prometheus.minioExporter; +in { + options = { + services.prometheus.minioExporter = { + enable = mkEnableOption "prometheus minio exporter"; + + port = mkOption { + type = types.int; + default = 9290; + description = '' + Port to listen on. + ''; + }; + + listenAddress = mkOption { + type = types.nullOr types.str; + default = null; + example = "0.0.0.0"; + description = '' + Address to listen on for web interface and telemetry. + ''; + }; + + minioAddress = mkOption { + type = types.str; + example = "https://10.0.0.1:9000"; + description = '' + The URL of the minio server. + Use HTTPS if Minio accepts secure connections only. + ''; + }; + + minioAccessKey = mkOption { + type = types.str; + example = "BKIKJAA5BMMU2RHO6IBB"; + description = '' + The value of the Minio access key. + It is required in order to connect to the server. + ''; + }; + + minioAccessSecret = mkOption { + type = types.str; + description = '' + The calue of the Minio access secret. + It is required in order to connect to the server. + ''; + }; + + minioBucketStats = mkOption { + type = types.bool; + default = false; + description = '' + Collect statistics about the buckets and files in buckets. + It requires more computation, use it carefully in case of large buckets.. + ''; + }; + + extraFlags = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra commandline options when launching the minio exporter. + ''; + }; + + openFirewall = mkOption { + type = types.bool; + default = false; + description = '' + Open port in firewall for incoming connections. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + networking.firewall.allowedTCPPorts = optional cfg.openFirewall cfg.port; + + systemd.services.prometheus-minio-exporter = { + description = "Prometheus exporter for Minio server metrics"; + unitConfig.Documentation = "https://github.com/joe-pll/minio-exporter"; + wantedBy = [ "multi-user.target" ]; + after = optional config.services.minio.enable "minio.service"; + serviceConfig = { + DynamicUser = true; + Restart = "always"; + PrivateTmp = true; + WorkingDirectory = /tmp; + ExecStart = '' + ${pkgs.prometheus-minio-exporter}/bin/minio-exporter \ + -web.listen-address ${optionalString (cfg.listenAddress != null) cfg.listenAddress}:${toString cfg.port} \ + -minio.server ${cfg.minioAddress} \ + -minio.access-key ${cfg.minioAccessKey} \ + -minio.access-secret ${cfg.minioAccessSecret} \ + ${optionalString cfg.minioBucketStats "-minio.bucket-stats"} \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + }; + }; + }; +}