简体   繁体   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. I have a Python Azure Function that has a bunch of Python logging.error()/logging.info() messages. I like this approach (I'm fairly new to Python) as I can look at the run history and see key pieces of information about a run.我喜欢这种方法(我对 Python 还很陌生),因为我可以查看运行历史记录并查看有关运行的关键信息。

Azure Function run history looks like this: Azure Function 运行历史如下所示: 在此处输入图像描述

Example1:示例 1:

This Kusto query gets me the basics about a given run, but none of the specifics这个 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: Output:

在此处输入图像描述

Example2:示例 2:

This query gets me all the details I need, but I have to define the operation_id and InvocationId此查询为我提供了我需要的所有详细信息,但我必须定义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: Output:

在此处输入图像描述

I need to query specific keywords found in these logging() messages.我需要查询在这些logging()消息中找到的特定关键字。

How do I do this with a Kusto query?如何使用 Kusto 查询执行此操作?

You can use any of the string search operators , such as "has".您可以使用任何字符串搜索运算符,例如“has”。 If your logging message follows a certain convention you can use the parse operator to extract the relevant data into columns.如果您的日志消息遵循某种约定,您可以使用parse运算符将相关数据提取到列中。

Below is what ended up working for me.以下是最终为我工作的内容。

| where message contains "specific string in logging" | where message contains "specific string in logging" was the key. | where message contains "specific string in logging"是关键。 Here message has the logging string I was looking for.这里的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.

相关问题 使用 Azure Function 中的 Kusto.Data 访问 Azure 数据资源管理器 -- Kusto 发送请求失败 -- 本地调试工作 - Access Azure Data Explorer with Kusto.Data in Azure Function -- Kusto failed to send request -- local debugging works Azure Kusto - 在跟踪的消息字段上使用 extract() - Azure Kusto - Use extract() on message field from traces 从 Azure 函数应用程序摄取 Kusto 数据以 403 结束 - Kusto data ingestion from an Azure Function App ends with a 403 如何使用 Kusto 查询作为 Azure ML 的输入数据 - How to use Kusto query as input data to Azure ML Azure Function-App 未记录到控制台或 AppInsights - Azure Function-App is not logging to console or AppInsights 在 Azure Function 中禁用记录到 App Insights - Disable logging to App Insights in Azure Function "如何使用用户分配的托管标识访问 Azure 中 Function App Config 的 Key Vault" - How to use user-assigned managed identity to access Key Vault for Function App Config in Azure 如何在Azure功能应用程序中使用SignalR? - How to use SignalR in an Azure function app? 如何从 Function App 访问 Azure App Service 文件夹 - How to access Azure App Service folders from Function App 如何使用 Logic App 在 Azure 函数中读取 ServiceBus 队列消息? - How to read ServiceBus Queue message in Azure function using Logic App?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM