tbraun-de / Axoom.Extensions.Prometheus.Standalone

Exposing Prometheus metrics on .NET Core without MVC routing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Axoom.Extensions.Prometheus.Standalone

NuGet package Build status

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.

Usage

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"));
}

On Windows

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

About

Exposing Prometheus metrics on .NET Core without MVC routing

License:MIT License


Languages

Language:C# 91.9%Language:PowerShell 8.1%