Search code examples
javac#.netweb-servicesprometheus

When adding Prometheus instrumentation with Java or .NET, is the web server for metrics running in a separate thread?


When adding Prometheus instrumentation with a client library for Java https://github.com/prometheus/client_java or .NET https://github.com/prometheus-net/prometheus-net, does the instrumentation spin out a metrics web server in a separate thread of the microservice?

What if the instrumented microservice is already running as a web server on port 80, can we expose metrics on a different port let's say 9001 with a separate instrumentation web server running in the same microservice?


Solution

  • It depends oh how you are using those libraries.

    For example, as shown at Quick start of linked by you library, you can start additional server on separate port, just for purposes of exposing metrics.

    But you also can expose metrics using your current routing, for example like shown at ASP.NET Web API exporter part of documentation.