Analyze logs
Once you enabled log data collection from your Spring Apps Service into the Log Analytics workspace, you want to start querying this data. You can use the following guidance to perform this task:
Use this guidance to:
- Show logs entries containing errors or exceptions
- Show ingress log entries
-
Show container log entries
Before you start reviewing logs, generate some log entries by navigating to the api-gateway URL and, from the PetClinic home page, performing the following tasks:
- Navigate to the Owners page, select a few names from the list
- For a few owners you selected, use the Edit Owner button to attempt modifying their information (for example, try setting the telephone number to an invalid value) and use the Add New Pet button to attempt to add a pet (for example, select the Submit button without providing the pet name).
Step by step guidance
-
Go to the Azure portal and navigate to the page displaying the Log Analytics workspace you created in the previous task.
-
Select Logs and, if needed, close the default Queries pane.
-
On the Tables tab, review the list of tables and verify that they include
AppPlatformContainerEventLogs
,AppPlatformIngressLogs
,AppPlatformLogsforSpring
,AppPlatformSystemLogs
,AzureMetrics
andAppPlatformBuildLogs
.Not all of these categories might be available at this point yet. It might take extra time for the logging data to appear in the Log Analytics workspace. If needed, wait for a few minutes and refresh the web page displaying the Azure portal.
-
In the query editor, enter the following query and select Run.
AppPlatformLogsforSpring | where Log contains "error" or Log contains "exception" | project TimeGenerated , ServiceName , AppName , InstanceName , Log
The results of the query will display the log entries that represent error or exception events.
-
In the query editor, replace the previous query with the following one and select Run.
AppPlatformIngressLogs | where TimeGenerated > ago(1h) | project TimeGenerated, Host, Request, Status, BodyBytesSent, RequestTime, ReqId, RequestHeaders | sort by TimeGenerated
The results of the query will display the ingress logs.
-
In the query editor, replace the previous query with the following one and select Run.
AppPlatformContainerEventLogs | where TimeGenerated > ago(1h) | sort by TimeGenerated
The results of the query will display the container event logs.
-
You can also display the results of the queries by using a time chart. To do so, replace the previous query with the following one and select Run.
AppPlatformContainerEventLogs | where TimeGenerated > ago(1h) | sort by TimeGenerated | summarize count() by bin(TimeGenerated, 5m), Event | render timechart
-
In the list of results, select the Chart tab to display the visual representation of the query results. You might select Pin to and then select Azure dashboard to pin this chart to the Home page of the Azure portal.