I'm updating my ASP.NET Core application to use OpenTelemetry for metrics collection, transitioning from the Prometheus library.
Previously, I had a specific server for my Prometheus metrics endpoint with the following configuration:
services.AddMetricServer(options => options.Port = 4000);
Now, I'm adding the OpenTelemetry Prometheus scraping endpoint like this:
app.UseOpenTelemetryPrometheusScrapingEndpoint();
However, this scraping endpoint is being exposed on the same HTTP server as my main application, which runs on port 5002. But in my Kubernetes environment, the metrics endpoint needs to be available on a different port (4000) while my application itself is still served on port 5002.
Is there a way to configure OpenTelemetry’s Prometheus scraping endpoint to be exposed on port 4000, while the main application continues to run on port 5002?
I've already tried:
app.UseOpenTelemetryPrometheusScrapingEndpoint(
context =>context.Connection.LocalPort == 4000);
Thanks in advance!
So just found out, we need to expose the application in two urls, so adding this variable do the trick:
ASPNETCORE_URLS="http://+:5002;http://+:4000"