Skip to main content
A complete walkthrough of instrumenting a .NET service using prometheus-net, the most widely adopted .NET Prometheus client. See the overview for the general approach.

1. Add the dependency

2. Register custom metrics and expose /metrics

prometheus-net automatically registers .NET runtime metrics (GC, JIT, thread pool, exceptions) and process metrics. KestrelMetricServer starts a standalone metrics endpoint on a dedicated port.
If you’re already running ASP.NET Core, use app.UseMetricServer() and app.UseHttpMetrics() to expose /metrics on your main app port — UseHttpMetrics also automatically tracks HTTP request durations, status codes, and route labels. Just point ops.json at your main app port.

3. Declare the metrics endpoint in ops.json

4. Visualize with a community dashboard

To import: in Grafana, go to Dashboards → New → Import, enter the dashboard ID, and select your LocalOps Prometheus data source. You’ll instantly see GC heap usage, JIT activity, thread pool stats, exception rates, and HTTP request throughput. Your custom application metrics (emails_sent_total, etc.) can be charted alongside.