dotnet-monitor容器准备
- 增加 Docker image 作为目标容器的sidecar 容器.
- 暴露端口
52323
#dotnet-monitor映射端口. - 增加容器启动命令参数
--no-auth
# 简单粗暴的让所有的API都不要鉴权. - 添加环境变量
DOTNETMONITOR_DiagnosticPort__ConnectionMode
=Listen
# 必须的.DOTNETMONITOR_DiagnosticPort__EndpointName
=/my_diagnostic_volume/diag.sock
# 目标容器配置的DOTNET_DiagnosticPorts中的address.DOTNETMONITOR_Storage__DumpTempFolder
=/my_diagnostic_volume/dump_files
# dump内存是用的目录.DOTNETMONITOR_Urls
=http://+:52323
# dotnet-monitor要提供服务在什么端口上. dotnet-monitor默认用的就是52323.
至此, 所有的配置就都完成了.
使用dotnet-monitor 来dump目标容器的内存文件Get 请求
/dump
endpoint 即可下载内存转储文件.wget ip:52323/dump -O my_target_application_memory_dump.dmp
| Route| Description| Version Introduced || ---------------- | ------------------------------------------------------------------ | ------------------ || /processes| Gets detailed information about discoverable processes.| 6.0|| /dump| Captures managed dumps of processes without using a debugger.| 6.0|| /gcdump| Captures GC dumps of processes.| 6.0|| /trace| Captures traces of processes without using a profiler.| 6.0|| /metrics| Captures metrics of a process in the Prometheus exposition format. | 6.0|| /livemetrics| Captures live metrics of a process.| 6.0|| /stacks| [Experimental] Gets the current callstacks of all .NET threads.| 7.0|| /logs| Captures logs of processes.| 6.0|| /info| Gets info about dotnet monitor.| 6.0|| /operations| Gets egress operation status or cancels operations.| 6.0|| /collectionrules | Gets the current state of collection rules.| 6.3|
所有可用的API以及解释, 请看这里API's在之后的问内存文件的分析可以使用
dotnet-dump
程序.更多高级用法请查看, 例如可以配置内存每增加100Mb就触发dump内存文件.相关链接https://learn.microsoft.com/zh-cn/dotnet/core/diagnostics/dotnet-monitorhttps://learn.microsoft.com/zh-cn/dotnet/core/diagnostics/dotnet-dumphttps://learn.microsoft.com/zh-cn/dotnet/core/diagnostics/diagnostic-porthttps://github.com/dotnet/dotnet-monitor/blob/main/README.mdhttps://devblogs.microsoft.com/dotnet/announcing-dotnet-monitor-in-net-6/
【使用dotnet-monitor sidecar模式 dump docker运行的dotnet程序.】
推荐阅读
- 如何使用支付宝付款(支付宝付款怎么追回)
- 支付宝使用详细教程(支付宝怎么扫码付款)
- 支付宝怎么规范使用(支付宝本人已故还可以使用吗)
- 怎样使用支付宝(支付宝不绑卡怎样付款)
- 支付宝怎么使用教程(支付宝怎么玩可以挣钱)
- 支付宝使用方法(支付宝怎么绑银行卡)
- 一次 Redis 事务使用不当引发的生产事故
- 还在使用@Autowrired注入?不妨试试@RequiredArgsConstructor
- Java并发编程 | Synchronized原理与使用
- python3使用mutagen进行音频元数据处理