[英]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_id
和InvocationId
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.