I want to monitor my ASP.NET Core MVC application with Prometheus. Following the instructions on https://github.com/prometheus-net/prometheus-net I managed to expose some metrics from my application as desired.
I have no previous experience using Prometheus and I am new to C# and ASP.NET Core MCV in general. Therefore I was interested in studying example projects.
Searching the web I've only managed to find minor code snippets, but nothing close to complete. Could someone guide me to example projects of this kind?
Some questions that I am interested in include
/metric
endpoint? Using a dedicated MetricController
or simply by adding the app.UseMetricServer()
in Startup.cs
as the Github project page suggests?/metric
endpoint? If so, how do you expose this port? (UseMetricServer
does not seem to accept a port)I wrote some examples here: https://github.com/PrometheusClientNet/Prometheus.Client.Examples
But, I use my own fork: https://github.com/PrometheusClientNet/Prometheus.Client.
You can adapt for original library or you can use mine.
Your questions:
Here is your choice. I prefer use Middleware(https://github.com/PrometheusClientNet/Prometheus.Client.AspNetCore) for Web and MetricServer(https://github.com/PrometheusClientNet/Prometheus.Client.MetricServer) for Console
Best way, use /metrics
the same port as the application. If this is not possible, then I need details
You can use my library: https://github.com/PrometheusClientNet/Prometheus.Client.HttpRequestDurations. Or just grab code from my repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With