This library provides a minimalist HTTP server for exposing Prometheus metrics on .NET Core without MVC routing. Extends the Nexogen Prometheus library.
It is intended as a replacement for the Nexogen.Libraries.Metrics.Prometheus.Standalone library. It uses Microsoft.AspNetCore.Http instead of NETStandard.HttpListener for better reliability.
Add/use the Prometheus server by using the default configuration (Port: 5000).
public void ConfigureServices(IServiceCollection services)
{
services
.AddOptions()
.AddPrometheusServer();
}
Or override the default configuration by providing a configuration entry in the appsetting.json
:
{
"PrometheusServer": {"Port": 5000}
}
public void ConfigureServices(IServiceCollection services)
{
services
.AddOptions()
.AddPrometheusServer(Configuration.GetSection("PrometheusServer"));
}
You will need to run the following in an Admin PowerShell once to allow non-admin processes to bind to port 5000:
netsh http add urlacl http://*:5000/ user=$env:USERDOMAIN\$env:USERNAME