mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Merge pull request #2985 from sparky8251/prometheus
Add Prometheus exporters
This commit is contained in:
commit
690fb65cd8
@ -106,6 +106,7 @@ using Microsoft.AspNetCore.Http.Extensions;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
||||||
|
using Prometheus.DotNetRuntime;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations
|
namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
@ -259,6 +260,12 @@ namespace Emby.Server.Implementations
|
|||||||
|
|
||||||
_startupOptions = options;
|
_startupOptions = options;
|
||||||
|
|
||||||
|
// Initialize runtime stat collection
|
||||||
|
if (ServerConfigurationManager.Configuration.EnableMetrics)
|
||||||
|
{
|
||||||
|
DotNetRuntimeStatsBuilder.Default().StartCollecting();
|
||||||
|
}
|
||||||
|
|
||||||
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
|
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
|
||||||
|
|
||||||
_networkManager.NetworkChanged += OnNetworkChanged;
|
_networkManager.NetworkChanged += OnNetworkChanged;
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.3" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.3" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.3" />
|
||||||
<PackageReference Include="Mono.Nat" Version="2.0.1" />
|
<PackageReference Include="Mono.Nat" Version="2.0.1" />
|
||||||
|
<PackageReference Include="prometheus-net.DotNetRuntime" Version="3.3.1" />
|
||||||
<PackageReference Include="ServiceStack.Text.Core" Version="5.8.0" />
|
<PackageReference Include="ServiceStack.Text.Core" Version="5.8.0" />
|
||||||
<PackageReference Include="sharpcompress" Version="0.25.0" />
|
<PackageReference Include="sharpcompress" Version="0.25.0" />
|
||||||
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.1.0" />
|
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.1.0" />
|
||||||
|
@ -43,6 +43,8 @@
|
|||||||
<PackageReference Include="CommandLineParser" Version="2.7.82" />
|
<PackageReference Include="CommandLineParser" Version="2.7.82" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.3" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" />
|
||||||
|
<PackageReference Include="prometheus-net" Version="3.5.0" />
|
||||||
|
<PackageReference Include="prometheus-net.AspNetCore" Version="3.5.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
||||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
|
||||||
|
@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Builder;
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Prometheus;
|
||||||
|
|
||||||
namespace Jellyfin.Server
|
namespace Jellyfin.Server
|
||||||
{
|
{
|
||||||
@ -69,9 +70,19 @@ namespace Jellyfin.Server
|
|||||||
app.UseJellyfinApiSwagger();
|
app.UseJellyfinApiSwagger();
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
if (_serverConfigurationManager.Configuration.EnableMetrics)
|
||||||
|
{
|
||||||
|
// Must be registered after any middleware that could chagne HTTP response codes or the data will be bad
|
||||||
|
app.UseHttpMetrics();
|
||||||
|
}
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
|
if (_serverConfigurationManager.Configuration.EnableMetrics)
|
||||||
|
{
|
||||||
|
endpoints.MapMetrics(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/') + "/metrics");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.Use(serverApplicationHost.ExecuteHttpHandlerAsync);
|
app.Use(serverApplicationHost.ExecuteHttpHandlerAsync);
|
||||||
|
@ -19,6 +19,11 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableUPnP { get; set; }
|
public bool EnableUPnP { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to enable prometheus metrics exporting.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableMetrics { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the public mapped port.
|
/// Gets or sets the public mapped port.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -246,6 +251,7 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
PublicHttpsPort = DefaultHttpsPort;
|
PublicHttpsPort = DefaultHttpsPort;
|
||||||
HttpServerPortNumber = DefaultHttpPort;
|
HttpServerPortNumber = DefaultHttpPort;
|
||||||
HttpsPortNumber = DefaultHttpsPort;
|
HttpsPortNumber = DefaultHttpsPort;
|
||||||
|
EnableMetrics = false;
|
||||||
EnableHttps = false;
|
EnableHttps = false;
|
||||||
EnableDashboardResponseCaching = true;
|
EnableDashboardResponseCaching = true;
|
||||||
EnableCaseSensitiveItemIds = true;
|
EnableCaseSensitiveItemIds = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user