Exposing .NET application metrics to Prometheus

The prometheus-net NuGet package provides a set of default metric collectors and a MetricServer class that provides the instrumentation endpoint that Prometheus hooks into. This package is great for adding Prometheus support to any app. The metrics are provided by a self-hosted HTTP endpoint, and you can provide custom metrics for your application.

In the dockeronwindows/ch11-api-with-metrics image, I've added Prometheus support into a Web API project. The code to configure and start the metrics endpoint is in the PrometheusServer class:

public static void Start(){  _Server = new MetricServer(50505);  _Server.Start();}

This starts a new MetricServer instance listening on port 50505 and running ...

Get Docker on Windows - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.