簡體   English   中英

如何使用 Kusto 訪問 Azure Function 應用程序代碼 logging() 消息?

[英]How to use Kusto to access Azure Function app code logging() message?

I have a Python Azure Function that has a bunch of Python logging.error()/logging.info() messages. 我喜歡這種方法(我對 Python 還很陌生),因為我可以查看運行歷史記錄並查看有關運行的關鍵信息。

Azure Function 運行歷史如下所示: 在此處輸入圖像描述

示例 1:

這個 Kusto 查詢讓我了解了有關給定運行的基礎知識,但沒有任何細節

requests
| project timestamp, id, operation_Name, success, resultCode, duration, operation_Id, cloud_RoleName, invocationId=customDimensions['InvocationId']
| where timestamp > ago(6d)
| where cloud_RoleName =~ 'functionAppName' and operation_Name =~ 'functionName'
| order by timestamp asc

Output:

在此處輸入圖像描述

示例 2:

此查詢為我提供了我需要的所有詳細信息,但我必須定義operation_idInvocationId

union traces
| union exceptions
| where timestamp > ago(30d)
| where operation_Id == '<biglongstring>'
| where customDimensions['InvocationId'] == '<biglongstring1>'
| order by timestamp asc
| project timestamp, message = iff(message != '', message, iff(innermostMessage != '', innermostMessage, customDimensions.['prop__{OriginalFormat}'])), logLevel = customDimensions.['LogLevel']

Output:

在此處輸入圖像描述

我需要查詢在這些logging()消息中找到的特定關鍵字。

如何使用 Kusto 查詢執行此操作?

您可以使用任何字符串搜索運算符,例如“has”。 如果您的日志消息遵循某種約定,您可以使用parse運算符將相關數據提取到列中。

以下是最終為我工作的內容。

| where message contains "specific string in logging" | where message contains "specific string in logging"是關鍵。 這里的message有我正在尋找的日志記錄字符串。

union traces
| union exceptions
| where timestamp > ago(30d)
| where message contains "specific string in logging"
| order by timestamp asc
| project timestamp, message = iff(message != '', message, iff(innermostMessage != '', innermostMessage, customDimensions.['prop__{OriginalFormat}'])), logLevel = customDimensions.['LogLevel']

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM