Skip to content

Inconsistent metrics being gathered from ASP.NET Core applications #3603

Open
@joaofbantunes

Description

@joaofbantunes

Description

Disclaimer: no idea if I should file this here or in the ASP.NET Core repo, but hopefully if it's not the right place, you can direct me there.

I was trying to gather some metrics using dotnet monitor, in order to feed them into Prometheus. While doing this, working with Docker Compose, I noticed that I wasn't able to get all the Kestrel related metrics (as seen here).

When running directly on Windows though, all the metrics I expected were there. To try to get to the bottom of it, removing any possible specificities of my application, ran the same tests using just the result of dotnet new web. On Windows, everything looked fine, but running it on WSL, I got the same issues as I saw in the container.

To try to create a repro to share with you, went down a rabbit hole of testing different scenarios, getting very inconsistent results:

Running on Windows

To run on Windows, executed:

  • dotnet new web -o Default && cd Default && dotnet run --environment Production --urls http://*:8000
  • dotnet-monitor collect --no-auth --urls "http://*:52323" --configuration-file-path "./monitor-config.json"
    (you can find the monitor-config.json file here)

The output of this run can be seen here.

Running on WSL

To run on WSL, executed exactly the same as above, with the results available here.

Running in a container

To run on Docker, executed:

  • docker run --rm -it -p 8000:80 --mount "source=dotnet-tmp,target=/tmp" mcr.microsoft.com/dotnet/sdk:7.0-alpine /bin/sh -c "dotnet new web -o App && cd App && dotnet run -c Release --environment Production --urls http://*:80"
  • docker run -e DotnetMonitor_Metrics__Providers__0__ProviderName="Microsoft-AspNetCore-Server-Kestrel" -e DotnetMonitor_Metrics__Providers__1__ProviderName="Microsoft.AspNetCore.Hosting" -e DotnetMonitor_Metrics__Providers__2__ProviderName="System.Runtime" -it --rm -p 52323:52323 --mount "source=dotnet-tmp,target=/tmp" mcr.microsoft.com/dotnet/monitor collect --urls http://*:52323 --no-auth

The output of this run can be seen here.

Running the ASP.NET Core sample app in a container

Also remembered to try the ASP.NET Core sample app:

  • docker run --rm -it -p 8000:80 --mount "source=dotnet-tmp,target=/tmp" mcr.microsoft.com/dotnet/samples:aspnetapp
  • docker run -e DotnetMonitor_Metrics__Providers__0__ProviderName="Microsoft-AspNetCore-Server-Kestrel" -e DotnetMonitor_Metrics__Providers__1__ProviderName="Microsoft.AspNetCore.Hosting" -e DotnetMonitor_Metrics__Providers__2__ProviderName="System.Runtime" -it --rm -p 52323:52323 --mount "source=dotnet-tmp,target=/tmp" mcr.microsoft.com/dotnet/monitor collect --urls http://*:52323 --no-auth

The output of this run can be seen here.

As you can see, the various results are inconsistent, not at all what I was expecting. Don't if it's a bug, or an environmental thing, but I have no idea what might be the issue.

Configuration

Windows information: Windows 11 Pro, Version 22H2, OS build 22621.1105, Experience Windows Feature Experience Pack 1000.22638.1000.0

Ubuntu version in WSL: Ubuntu 20.04.5 LTS

Docker Desktop version: 4.16.3

.NET Version on Windows: 7.0.200-preview.22628.1

.NET Version in Ubuntu: 7.0.102

Other information

I also tried on macOS, and had similar results to Windows.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions