From 564111ea20a5cea831879fefcff9d5a84de31663 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 29 Aug 2022 12:49:09 -0500 Subject: add Metrics options --- src/slskd/Core/Options.cs | 82 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index bb525003..6a435db1 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -235,6 +235,13 @@ namespace slskd [RequiresRestart] public LoggerOptions Logger { get; init; } = new LoggerOptions(); + /// + /// Gets metrics options. + /// + [Validate] + [RequiresRestart] + public MetricsOptions Metrics { get; init; } = new MetricsOptions(); + /// /// Gets feature options. /// @@ -622,15 +629,6 @@ namespace slskd /// public class FeatureOptions { - /// - /// Gets a value indicating whether prometheus metrics should be collected and published. - /// - [Argument(default, "prometheus")] - [EnvironmentVariable("PROMETHEUS")] - [Description("enable collection and publishing of prometheus metrics")] - [RequiresRestart] - public bool Prometheus { get; init; } = false; - /// /// Gets a value indicating whether swagger documentation and UI should be enabled. /// @@ -730,6 +728,72 @@ namespace slskd public string Loki { get; init; } = null; } + /// + /// Metrics options. + /// + public class MetricsOptions + { + /// + /// Gets a value indicating whether the metrics endpoint should be enabled. + /// + [Argument(default, "metrics")] + [EnvironmentVariable("METRICS")] + [Description("enable metrics")] + [RequiresRestart] + public bool Enabled { get; init; } = false; + + /// + /// Gets the url for the metrics endpoint. + /// + [Argument(default, "metrics-url")] + [EnvironmentVariable("METRICS_URL")] + [Description("url for metrics")] + [RequiresRestart] + public string Url { get; init; } = "/metrics"; + + /// + /// Gets metrics endpoint authentication options. + /// + [Validate] + public AuthenticationOptions Authentication { get; init; } = new AuthenticationOptions(); + + /// + /// Metrics endpoint authentication options. + /// + public class AuthenticationOptions + { + /// + /// Gets a value indicating whether authentication should be disabled. + /// + [Argument(default, "metrics-no-auth")] + [EnvironmentVariable("METRICS_NO_AUTH")] + [Description("disable authentication for metrics requests")] + [RequiresRestart] + public bool Disabled { get; init; } = false; + + /// + /// Gets the username for the metrics endpoint. + /// + [Argument(default, "metrics-username")] + [EnvironmentVariable("METRICS_USERNAME")] + [Description("username for metrics")] + [StringLength(255, MinimumLength = 1)] + [RequiresRestart] + public string Username { get; init; } = Program.AppName; + + /// + /// Gets the password for the metrics endpoint. + /// + [Argument(default, "metrics-password")] + [EnvironmentVariable("METRICS_PASSWORD")] + [Description("password for metrics")] + [StringLength(255, MinimumLength = 1)] + [Secret] + [RequiresRestart] + public string Password { get; init; } = Program.AppName; + } + } + /// /// Soulseek client options. /// -- cgit v1.2.3