diff --git a/modules/services/jellyfin/default.nix b/modules/services/jellyfin/default.nix index 93d2cb6..d381b42 100644 --- a/modules/services/jellyfin/default.nix +++ b/modules/services/jellyfin/default.nix @@ -4,6 +4,11 @@ let cfg = config.my.services.jellyfin; domain = config.networking.domain; port = 8096; + # enable monitoring + jellyfin-with-metrics = pkgs.jellyfin.overrideAttrs (attrs: { + # with this patch the default setting for metrics is changed + patches = attrs.patches ++ [ ./enable-metrics.patch ]; + }); in { options.my.services.jellyfin = with lib; { @@ -13,8 +18,26 @@ in config = lib.mkIf cfg.enable { services.jellyfin = { enable = true; + package = jellyfin-with-metrics; }; + services.prometheus = { + scrapeConfigs = [ + { + job_name = "jellyfin"; + static_configs = [ + { + targets = [ "127.0.0.1:${toString cfg.port}" ]; + labels = { + instance = config.networking.hostName; + }; + } + ]; + } + ]; + }; + # sadly the metrics do not contain application specific metrics, only c# -> no dashboard + my.services.nginx.virtualHosts = [ { subdomain = "media"; diff --git a/modules/services/jellyfin/enable-metrics.patch b/modules/services/jellyfin/enable-metrics.patch new file mode 100644 index 0000000..1544512 --- /dev/null +++ b/modules/services/jellyfin/enable-metrics.patch @@ -0,0 +1,13 @@ +diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs +index 07f02d1879..0f1c2e0cb8 100644 +--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs ++++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs +@@ -66,7 +66,7 @@ namespace MediaBrowser.Model.Configuration + /// + /// Gets or sets a value indicating whether to enable prometheus metrics exporting. + /// +- public bool EnableMetrics { get; set; } = false; ++ public bool EnableMetrics { get; set; } = true; + + public bool EnableNormalizedItemByNameIds { get; set; } = true; +