Function Apps To Log Analytics
Description:
Follow these steps to get your Function App custom logs to show up in Log Analytics
To Resolve:
-
Inside your Function App, go to Diagnostic Settings and have it send all of its logs to Log Analytics just like any other resource
-
Inside App Insights go to Properties and make sure it is pointing to log analytics
-
If you want to see the output of a log, you have two places to go for now:
- Inside Application Insights => Logs => you can type
traces
and run. It should have your pythonlogging.info("something")
statements - Example for a function called
GetProcessID
:
1 2
traces | where customDeminsions.Category == "Function.GetProcessID.User"
- Inside Log Analytics => Logs => you can type
FunctionAppLogs
and run. It should have your pythonlogging.info("something")
statements
1 2 3 4 5 6 7 8
FunctionAppLogs | where FunctionName == "GetProcessID" # another example to get Exceptions FunctionAppLogs | where ExceptionDetails != "" | order by TimeGenerated asc
- Inside Application Insights => Logs => you can type
-
Actually, for best results, I have been typing
AppTraces
in Log Analytics to get my logging statement outputs.
1
2
3
4
5
6
7
8
9
10
11
12
AppTraces
| where OperationName == "Get-Status"
| where TimeGenerated > ago(20m)
| sort by TimeGenerated desc
| project TimeGenerated, Message, OperationId
# Variation you could try:
AppTraces
| where OperationName == "Get-Status"
| where TimeGenerated > ago(20m)
| sort by TimeGenerated desc
| summarize by OperationId, TimeGenerated, Message
Comments