Reputation: 2008
I have a Python Azure Function that produces custom logging messages when the Function executes. I'm able to pull specific info from the JSON inside the log strings (thank you @yoni).
How do I correctly combine 2 or more Kusto queries which parse different logging
messages into a single query?
Example:
logging()
messages (prepended with #######
)Kusto query (spacing for readability):
let varLookback = ago(1d);
let varPath =
union traces
| union exceptions
| where timestamp > varLookback
| where message contains "####### Will write to"
//Pulls filePath out of Python logging string
| extend parsedMessage = todynamic(trim(@"#######",substring(message, 21)))
| project operation_Id, timestamp, filePath = parsedMessage;
union traces
| union exceptions
| where timestamp > varLookback
| where message contains "####### EventGrid trigger processing an event"
//Pulls message JSON out of Python logging string
| extend parsedMessage = todynamic(trim(@"#######",substring(message, 46)))
//Parses fileName and contentLength from message JSON
| project operation_Id, timestamp, fileName = split(parsedMessage["data"]["blobUrl"], "/")[6], contentLength = parsedMessage["data"]["contentLength"]
//I've tried different join kinds here (inner, inner_unique, right_outer, etc. same erroneous results)
| join varPath on $left.operation_Id == $right.operation_Id
| order by timestamp asc
Issue:
EDIT 1:
After some troubleshooting, there seems to be a core discrepancy between the number of Function executions and the number of Function executions that contain the custom logging
message.
Verified count of Function executions in last 1d: 36
(this Function moves files between two storage accounts. I verified that 36 files were moved in last 1d)
Count of Function execution logging
messages with keyword: 23
Why are some Function executions not showing custom logging
?
Upvotes: 1
Views: 1182
Reputation: 25995
a. Make sure you've chosen the right join
kind (default is innerunique
(doc))
join
legs in your question would help (as the total number of records seem low enough to fit)Unrelated, perf tips:
Prefer using has
over contains
whenever possible (doc)
trim()
(doc) takes a regular expression as its first argument. Based on the content of your message
s, see if you can choose a better operator function, that doesn't require a regular expression (e.g. parse
operator or substring()
function)
Upvotes: 3