[英]How can I monitor number of instances of a function app when it scales out?
一種方法是使用 App Insights 查詢。 這將為您提供過去 24 小時內每 30 秒運行的不同實例的數量。
您可以根據自己的選擇編輯粒度和時間跨度,但請記住,粒度越大,查詢的准確度就越低,因為實例可以隨時啟動和關閉。
let grainTime = 30sec;
traces
| where timestamp >= ago(24h)
| summarize ['rate/minute'] = dcount(cloud_RoleInstance) by bin(timestamp, grainTime)
| render timechart
然后您可以將其固定到您的儀表板!
作為預覽功能,現在我們可以讓 scale controller 發出帶有推理的日志,以幫助理解應用程序在不同點擴展的原因和方式。 您必須將 function 配置添加為SCALE_CONTROLLER_LOGGING_ENABLED=AppInsights:Verbose
。 然后您可以查詢您的規模 controller 日志以了解此 Microsoft 文檔中的原因和實例計數。
我修改了鏈接文檔中的 kusto 查詢,使其在過去 24 小時內具有 function 縮放圖
traces
| where customDimensions.Category == "ScaleControllerLogs"
| where customDimensions.Action == "ScaleResult"
| where customDimensions.AppName == "my-function-app-name"
| extend currentInstanceCount = toint(customDimensions.CurrentInstanceCount)
| make-series rawInstanceCounts = max(currentInstanceCount) default=-1 on timestamp in range(ago(24h), now(), 5m)
| extend instanceCountsForwardFilled = series_fill_forward(rawInstanceCounts, -1)
| project timestamp, instanceCountsForwardFilled
| render timechart
您還可以將 controller 規模的日志發送到 Blob 存儲。 在上面的示例中,我選擇了 AppInsights 進行快速查詢。 此外,為了避免應用洞察定價影響,請在了解擴展行為后考慮禁用配置參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.