診斷監視和收集公用程式 (dotnet-monitor)

本文適用於: ✔️ dotnet-monitor 6.0.0 版與更新版本

安裝

有兩種方式可以下載 dotnet-monitor

  • dotnet 全域工具:

    若要安裝最新發行版本的 dotnet-monitorNuGet 套件,請使用 dotnet tool install 命令:

    dotnet tool install --global dotnet-monitor
    
  • Docker 映像:

    下載 Docker 映像,以便在多容器環境中使用:

    docker pull mcr.microsoft.com/dotnet/monitor
    

概要

dotnet-monitor [-h|--help] [--version] <command>

描述

dotnet-monitor 全域工具是監視生產環境中的 .NET 應用程式,以及收集診斷成品 (例如傾印、追蹤、記錄和計量) 的方式,無論是隨選或使用自動化規則依指定條件收集。

選項。

  • --version

    顯示 dotnet-monitor 公用程式的版本。

  • -h|--help

    顯示命令列說明。

命令

Command
dotnet monitor collect
dotnet monitor config show
dotnet monitor generatekey

dotnet-monitor collect

監視 .NET 應用程式、允許收集診斷成品,並將結果傳送至所選目的地。

概要

dotnet-monitor collect [-h|--help] [-u|--urls] [-m|--metrics] [--metricUrls] [--diagnostic-port] [--no-auth] [--temp-apikey] [--no-http-egress]

選項。

  • -h|--help

    顯示命令列說明。

  • -u|--urls <urls>

    HTTP API 的繫結。 預設值為 https://localhost:52323

  • -m|--metrics [true|false]

    啟用要 /metrics 路由的計量發佈。 預設為 true

  • --metricUrls <urls>

    計量 HTTP API 的繫結。 預設值為 http://localhost:52325

  • --diagnostic-port <path>

    執行階段執行個體可以連線的診斷連接埠所用的完整路徑和檔案名稱。 指定這個選項會使 dotnet-monitor 進入「接聽」模式。 未指定時,dotnet-monitor 處於「連線」模式。

    在 Windows 上,這必須是有效的具名管道名稱。 在 Linux 和 macOS 上,這必須是有效的 Unix 網域通訊端路徑。

  • --no-auth

    停用 API 金鑰驗證。 預設值為 false

    強烈建議不要在生產環境中使用這個選項。

  • --temp-apikey

    產生 dotnet-monitor 執行個體的暫時 API 金鑰。

  • --no-http-egress

    透過 HTTP 回應停用診斷成品的輸出。 指定時,必須使用輸出提供者輸出成品。

dotnet-monitor config show

顯示設定,如同使用這些參數執行 dotnet-monitor collect 一樣。

概要

dotnet-monitor config show [-h|--help] [-u|--urls] [-m|--metrics] [--metricUrls] [--diagnostic-port] [--no-auth] [--temp-apikey] [--no-http-egress] [--level] [--show-sources]

選項。

  • -h|--help

    顯示命令列說明。

  • -u|--urls <urls>

    HTTP API 的繫結。 預設值為 https://localhost:52323

    此值會對應於設定做為 urls 索引鍵。

  • -m|--metrics [true|false]

    啟用要 /metrics 路由的計量發佈。 預設值為 true

    此值會對應於設定做為 Metrics:Enabled 索引鍵。

  • --metricUrls <urls>

    計量 HTTP API 的繫結。 預設值為 http://localhost:52325

    此值會對應於設定做為 Metrics:Endpoints 索引鍵。

  • --diagnostic-port <path>

    執行階段執行個體可以連線的診斷連接埠所用的完整路徑和檔案名稱。 指定這個選項會使 dotnet-monitor 進入「接聽」模式。 未指定時,dotnet-monitor 處於「連線」模式。

    在 Windows 上,這必須是有效的具名管道名稱。 在 Linux 和 macOS 上,這必須是有效的 Unix 網域通訊端路徑。

    此值會對應於設定做為 DiagnosticPort:EndpointName 索引鍵。

  • --no-auth

    停用 API 金鑰驗證。 預設值為 false

    強烈建議不要在生產環境中使用這個選項。

    此值未對應於設定。

  • --temp-apikey

    產生 dotnet-monitor 執行個體的暫時 API 金鑰。

    此值會對應於設定做為 Authentication:MonitorApiKey 索引鍵。

  • --no-http-egress

    透過 HTTP 回應停用診斷成品的輸出。 指定時,必須使用輸出提供者輸出成品。

    此值未對應於設定。

  • --level

    設定等級。 Full 設定可以顯示敏感性資訊。 有兩個等級:

    • Full - 任何值均未經過任何修訂的完整設定。
    • Redacted - 完整設定,但是已知祕密之類的敏感性資訊會經過修訂。
  • --show-sources

    識別提供每個有效設定值的設定來源。

dotnet-monitor generatekey

產生 HTTP 驗證的 API 金鑰和雜湊。

概要

dotnet-monitor generatekey [-h|--help] [-o|--output]

選項。

  • -h|--help

    顯示命令列說明。

  • -o|--output <Cmd|Json|MachineJson|PowerShell|Shell|Text>

    將 API 金鑰資訊寫入標準輸出的輸出格式。

    允許的值包括:

    • Cmd - 可在 Windows 命令提示字元或批次檔中使用的格式輸出。
    • Json - 以 JSON 物件的格式輸出。
    • MachineJson - 以 JSON 物件的格式輸出,而不需要註解和說明。 適用於自動化案例。
    • PowerShell - 以 PowerShell 提示和指令碼中可用的格式輸出。
    • Shell - 以 Linux 殼層中可用的格式輸出,例如 Bash。
    • Text - 以純文字格式輸出。

另請參閱