直接在宿主机上运行dotnet-monitor collect,同时运行一个dotnet程序,这样子访问http://127.0.0.1:52323/processes是可以获取到dotnet进程信息的。
但是通过docker运行,获取不到运行的dotnet进程。
monitor容器启动命令参数如下:
docker run -p 127.0.0.1:52323:52323/tcp --entrypoint dotnet-monitor --env DOTNETMONITOR_Authentication__MonitorApiKey__Subject=6fd7e657-ad6d-4a03-9689-7030397bb951 --env DOTNETMONITOR_Authentication__MonitorApiKey__PublicKey=eyJBZGRpdGlvbmFsRGF0YSI6e30sIkNydiI6IlAtMzg0IiwiS2V5T3BzIjpbXSwiS3R5IjoiRUMiLCJYIjoiaUhTV0x3aXJqcW10NFRKb3NPU3lpdDJBY2hxRXlIMDhqbF9KQUhVWDdxRkR4OEZmY0xYM1BtUFVZUWdqWkZFMSIsIlg1YyI6W10sIlkiOiJmT1pkWTBfbU05YW9aTXRIOGFFMHpoUHpNZnlPLUtUem1OVU93RXN0aDZaZXdHLWVEMHVtN1pwNGJKTE95c0wwIiwiS2V5U2l6ZSI6Mzg0LCJIYXNQcml2YXRlS2V5IjpmYWxzZSwiQ3J5cHRvUHJvdmlkZXJGYWN0b3J5Ijp7IkNyeXB0b1Byb3ZpZGVyQ2FjaGUiOnt9LCJDYWNoZVNpZ25hdHVyZVByb3ZpZGVycyI6dHJ1ZSwiU2lnbmF0dXJlUHJvdmlkZXJPYmplY3RQb29sQ2FjaGVTaXplIjoyNH19 mcr.microsoft.com/dotnet/monitor collect --no-auth --urls http://+:52323 --metricUrls http://+:52325
调用/processes控制台打印的日志信息如下:
{"Timestamp":"2022-03-14T03:53:14.6408465Z","EventId":5,"LogLevel":"Information","Category":"Microsoft.Diagnostics.Monitoring.WebApi.Controllers.DiagController","Message":"Written to HTTP stream.","State":{"Message":"Written to HTTP stream.","{OriginalFormat}":"Written to HTTP stream."},"Scopes":[{"Message":"SpanId:379d8dbadc602baa, TraceId:276fa80db9fae2c528dfdc35743d3bd2, ParentId:0000000000000000","SpanId":"379d8dbadc602baa","TraceId":"276fa80db9fae2c528dfdc35743d3bd2","ParentId":"0000000000000000"},{"Message":"ConnectionId:0HMG5DOII4V6Q","ConnectionId":"0HMG5DOII4V6Q"},{"Message":"RequestPath:/processes RequestId:0HMG5DOII4V6Q:00000003","RequestId":"0HMG5DOII4V6Q:00000003","RequestPath":"/processes"},{"Message":"Microsoft.Diagnostics.Monitoring.WebApi.Controllers.DiagController.GetProcesses (Microsoft.Diagnostics.Monitoring.WebApi)","ActionId":"64e6849f-a229-4329-b965-894a8c11b163","ActionName":"Microsoft.Diagnostics.Monitoring.WebApi.Controllers.DiagController.GetProcesses (Microsoft.Diagnostics.Monitoring.WebApi)"}]}