public PrometheusMiddleware(PrometheusOptions options) { _allowedHosts = new HashSet <string>(options.AllowedHosts ?? Array.Empty <string>()); _endpoint = string.IsNullOrWhiteSpace(options.Endpoint) ? "/metrics" : options.Endpoint.StartsWith("/") ? options.Endpoint : $"/{options.Endpoint}"; _apiKey = options.ApiKey; }
/// <summary> /// Add support for exposing a prometheus scaraping endpoint /// </summary> /// <param name="scrapeEndpointPath">Path where the scrape endpoint will be exposed</param> public static IApplicationBuilder UsePrometheusScraper(this IApplicationBuilder app, string scrapeEndpointPath) { var prometheusOptions = new PrometheusOptions { MapPath = scrapeEndpointPath, UseDefaultCollectors = false }; app.UsePrometheusServer(prometheusOptions); return(app); }
public PrometheusJob(PrometheusOptions options, ILogger <PrometheusJob> logger) { _enabled = options.Enabled; _logger = logger; _logger.LogInformation($"Prometheus integration is {(_enabled ? "enabled" : "disabled")}."); }