summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorMilan Pässler <milan@petabyte.dev>2021-03-12 11:11:16 +0100
committerMilan Pässler <milan@petabyte.dev>2021-03-12 11:11:16 +0100
commitb2bebd7cd5446c197ce6b3e8a38ef3686ae5ace0 (patch)
tree78b2ec61d88e9234a69ea125d4c67e4b546596aa /nixos
parent942bd5cc2f728c17775f853bc63944efd4b3cfb0 (diff)
nixos/prometheus-jitsi-exporter: init
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters.nix1
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/jitsi.nix40
-rw-r--r--nixos/tests/prometheus-exporters.nix23
3 files changed, 64 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix
index 940f28189371..fc5cee70fd9a 100644
--- a/nixos/modules/services/monitoring/prometheus/exporters.nix
+++ b/nixos/modules/services/monitoring/prometheus/exporters.nix
@@ -30,6 +30,7 @@ let
"dovecot"
"fritzbox"
"json"
+ "jitsi"
"keylight"
"lnd"
"mail"
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/jitsi.nix b/nixos/modules/services/monitoring/prometheus/exporters/jitsi.nix
new file mode 100644
index 000000000000..c93a8f98e552
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/exporters/jitsi.nix
@@ -0,0 +1,40 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.jitsi;
+in
+{
+ port = 9700;
+ extraOpts = {
+ url = mkOption {
+ type = types.str;
+ default = "http://localhost:8080/colibri/stats";
+ description = ''
+ Jitsi Videobridge metrics URL to monitor.
+ This is usually /colibri/stats on port 8080 of the jitsi videobridge host.
+ '';
+ };
+ interval = mkOption {
+ type = types.str;
+ default = "30s";
+ example = "1min";
+ description = ''
+ How often to scrape new data
+ '';
+ };
+ };
+ serviceOpts = {
+ serviceConfig = {
+ ExecStart = ''
+ ${pkgs.prometheus-jitsi-exporter}/bin/jitsiexporter \
+ -url ${escapeShellArg cfg.url} \
+ -host ${cfg.listenAddress} \
+ -port ${toString cfg.port} \
+ -interval ${toString cfg.interval} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ };
+ };
+}
diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix
index 89d17c9de8c0..9625aa4d274d 100644
--- a/nixos/tests/prometheus-exporters.nix
+++ b/nixos/tests/prometheus-exporters.nix
@@ -218,6 +218,29 @@ let
'';
};
+ jitsi = {
+ exporterConfig = {
+ enable = true;
+ };
+ metricProvider = {
+ systemd.services.prometheus-jitsi-exporter.after = [ "jitsi-videobridge2.service" ];
+ services.jitsi-videobridge = {
+ enable = true;
+ apis = [ "colibri" "rest" ];
+ };
+ };
+ exporterTest = ''
+ wait_for_unit("jitsi-videobridge2.service")
+ wait_for_open_port(8080)
+ wait_for_unit("prometheus-jitsi-exporter.service")
+ wait_for_open_port(9700)
+ wait_until_succeeds(
+ 'journalctl -eu prometheus-jitsi-exporter.service -o cat | grep -q "key=participants"'
+ )
+ succeed("curl -sSf 'localhost:9700/metrics' | grep -q 'jitsi_participants 0'")
+ '';
+ };
+
json = {
exporterConfig = {
enable = true;