|
1 | 1 | ---
|
2 |
| -title: "Tutorial: Observability of managed Java components" |
| 2 | +title: Observability of managed Java components |
3 | 3 | description: Learn how to retrieve logs of managed Java components.
|
4 | 4 | services: container-apps
|
5 | 5 | author: craigshoemaker
|
6 | 6 | ms.service: container-apps
|
7 | 7 | ms.custom: devx-track-extended-java
|
8 |
| -ms.topic: conceptual |
9 |
| -ms.date: 04/30/2024 |
| 8 | +ms.topic: how-to |
| 9 | +ms.date: 05/01/2024 |
10 | 10 | ms.author: cshoe
|
11 | 11 | zone_pivot_groups: container-apps-portal-or-cli
|
12 | 12 | ---
|
13 | 13 |
|
14 | 14 | # Tutorial: Observability of managed Java components
|
15 | 15 |
|
16 |
| -Java components include built-in observability features that could give you a holistic view of Java component health throughout its lifecycle. |
| 16 | +Java components include built-in observability features that can give you a holistic view of Java component health throughout its lifecycle. In this tutorial, you learn how to query logs messages generated by a Java component. |
17 | 17 |
|
18 | 18 | ## Prerequisites
|
19 | 19 |
|
20 | 20 | The following prerequisites are required for this tutorial.
|
21 | 21 |
|
22 | 22 | | Resource | Description |
|
23 | 23 | |---|---|
|
24 |
| -| Azure Log Analytics | To use the built-in observability features of managed Java components, ensure you set up your Azure Log Analytics for logging and monitoring in a managed environment as outlined in the document, either using **Log Analytics** or **Azure Monitor**. [Log storage and monitoring options in Azure Container Apps](log-options.md) | |
25 |
| -| Java component | Make sure to create at least one Java component in your environment, such as [Eureka](java-eureka-server.md) and [config server](java-config-server.md). | |
| 24 | +| Azure Log Analytics | To use the built-in observability features of managed Java components, ensure you set up Azure Log Analytics to use Log Analytics or *Azure Monitor*. For more information, see [Log storage and monitoring options in Azure Container Apps](log-options.md). | |
| 25 | +| Java component | Make sure to create at least one Java component in your environment, such as [Eureka Server](java-eureka-server.md) or [Config Server](java-config-server.md). | |
26 | 26 |
|
27 | 27 | ## Query log data
|
28 | 28 |
|
29 |
| -Log Analytics is a tool in the Azure portal used to view and analyze log data. Using Log Analytics, you can write Kusto queries to retrieve, sort, filter, and visualize the log data. These visualizations help you spot trends and identify issues with your application. You can work interactively with the query results or use them with other features such as alerts, dashboards, and workbooks. |
| 29 | +Log Analytics is a tool that helps you view and analyze log data. Using Log Analytics, you can write Kusto queries to retrieve, sort, filter, and visualize log data. These visualizations help you spot trends and identify issues with your application. You can work interactively with the query results or use them with other features such as alerts, dashboards, and workbooks. |
30 | 30 |
|
31 | 31 | ::: zone pivot="azure-portal"
|
32 | 32 |
|
33 |
| -To query Java component logs in Azure, begin by accessing your Azure Log Analytics workspace associated with your environment. From there, proceed by selecting **Logs** from the sidebar. |
| 33 | +1. Open the Azure portal and go to your Azure Log Analytics workspace. |
34 | 34 |
|
35 |
| -Focus your query on the Java component logs by utilizing the **ContainerAppSystemlogs_CL** table, which is found under the **CustomLogs** category in **Tables** tab. |
| 35 | +1. Select **Logs** from the sidebar. |
36 | 36 |
|
37 |
| -:::image type="content" source="media/java-components-logs/java-component-logs.png" alt-text="Screenshot of the Log Analytics Java component logs."::: |
| 37 | +1. In the query tab, under the *Tables* section, under *Custom Logs*, select the **ContainerAppSystemlogs_CL** table. |
38 | 38 |
|
39 |
| -The following Kusto query displays the log entries of Eureka Server for Spring component logs. |
| 39 | +1. Enter the following Kusto query to display Eureka Server logs for the Spring component. |
40 | 40 |
|
41 |
| -```kusto |
42 |
| -ContainerAppSystemLogs_CL |
43 |
| -| where ComponentType_s == 'SpringCloudEureka' |
44 |
| -| project Time=TimeGenerated, Type=ComponentType_s, Component=ComponentName_s, Message=Log_s |
45 |
| -| take 100 |
46 |
| -``` |
| 41 | + ```kusto |
| 42 | + ContainerAppSystemLogs_CL |
| 43 | + | where ComponentType_s == 'SpringCloudEureka' |
| 44 | + | project Time=TimeGenerated, Type=ComponentType_s, Component=ComponentName_s, Message=Log_s |
| 45 | + | take 100 |
| 46 | + ``` |
| 47 | +
|
| 48 | + :::image type="content" source="media/java-components-logs/java-component-logs.png" alt-text="Screenshot of the Log Analytics Java component logs."::: |
| 49 | +
|
| 50 | +1. Select the **Run** button to run the query. |
47 | 51 |
|
48 | 52 | ::: zone-end
|
49 | 53 |
|
50 | 54 | ::: zone pivot="azure-cli"
|
51 | 55 |
|
52 |
| -Java component logs can be queried using the [Azure CLI](/cli/azure/monitor/log-analytics). |
| 56 | +You query the component logs via the Azure CLI [log analytics](/cli/azure/monitor/log-analytics) extension. |
53 | 57 |
|
54 |
| -The following example Azure CLI queries output a table containing log records for the Eureka Server for Spring component. The `project` operator's parameters specify the table columns. The `$WORKSPACE_CUSTOMER_ID` variable contains the GUID of the Log Analytics workspace. |
| 58 | +1. Run the following command to create a variable for your Log Analytics workspace ID. |
55 | 59 |
|
56 |
| -# [Bash](#tab/bash) |
| 60 | + Make sure to replace `<WORKSPACE_ID>` with your Log Analytics workspace ID before running the query. |
57 | 61 |
|
58 |
| -```azurecli |
59 |
| -az monitor log-analytics query --workspace $WORKSPACE_CUSTOMER_ID --analytics-query "ContainerAppSystemLogs_CL | where ComponentType_s == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType_s, Component=ComponentName_s, Message=Log_s | take 5" --out table |
60 |
| -``` |
| 62 | + # [Bash](#tab/bash) |
61 | 63 |
|
62 |
| -# [PowerShell](#tab/powershell) |
| 64 | + ```azurecli |
| 65 | + SET $WORKSPACE_ID=<WORKSPACE_ID> |
| 66 | + ``` |
63 | 67 |
|
64 |
| -```powershell |
65 |
| -$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $WORKSPACE_CUSTOMER_ID -Query "ContainerAppSystemLogs_CL | where ComponentType_s == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType_s, Component=ComponentName_s, Message=Log_s | take 5" |
66 |
| -$queryResults.Results |
67 |
| -``` |
| 68 | + # [PowerShell](#tab/powershell) |
68 | 69 |
|
69 |
| ---- |
| 70 | + ```powershell |
| 71 | + $WORKSPACE_ID = "<WORKSPACE_ID>" |
| 72 | + ``` |
| 73 | +
|
| 74 | + --- |
| 75 | +
|
| 76 | +1. Run the following command to query the logs table. |
| 77 | +
|
| 78 | + # [Bash](#tab/bash) |
| 79 | +
|
| 80 | + ```azurecli |
| 81 | + az monitor log-analytics query \ |
| 82 | + --workspace $WORKSPACE_ID \ |
| 83 | + --analytics-query "ContainerAppSystemLogs_CL | where ComponentType_s == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType_s, Component=ComponentName_s, Message=Log_s | take 5" --out table |
| 84 | + ``` |
| 85 | +
|
| 86 | + # [PowerShell](#tab/powershell) |
| 87 | +
|
| 88 | + ```powershell |
| 89 | + $queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $WORKSPACE_ID -Query "ContainerAppSystemLogs_CL | where ComponentType_s == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType_s, Component=ComponentName_s, Message=Log_s | take 5" |
| 90 | + $queryResults.Results |
| 91 | + ``` |
| 92 | +
|
| 93 | + --- |
| 94 | +
|
| 95 | + The `project` operator's parameters specify the table columns. |
70 | 96 |
|
71 | 97 | ::: zone-end
|
72 | 98 |
|
73 | 99 | ## Query Java Component Log with Azure monitor
|
74 | 100 |
|
75 |
| -Azure Monitor is a comprehensive monitoring solution for collecting, analyzing, and responding to monitoring data from your cloud and on-premises environments. Azure Monitor can direct logs to one or more destinations, here we take Log Analytics workspace being a primary example of such a destination. |
| 101 | +You can query Azure Monitor for monitoring data for your Java component logs. |
76 | 102 |
|
77 | 103 | ::: zone pivot="azure-portal"
|
78 | 104 |
|
79 |
| -To query Java components in Azure using Azure Monitor, with Log Analytics workspace as the destination, you have two options: navigate directly to your Log Analytics workspace or access the logs through the Managed Environment's **Log** panel as follows. |
| 105 | +1. Open the Azure portal and go to your Container Apps environment. |
80 | 106 |
|
81 |
| -Focus your query on the Java component logs by utilizing the **ContainerAppSystemLogs** table, which is found under the **Container Apps** category in **Tables** tab. |
| 107 | +1. From the sidebar, under the *Monitoring* section, select **Logs**. |
82 | 108 |
|
83 |
| -:::image type="content" source="media/java-components-logs/java-component-logs.png" alt-text="Screenshot of the Log Analytics Java component logs portal location."::: |
| 109 | +1. In the query tab, in the *Tables* section, under the *Container Apps* heading, select the **ContainerAppSystemLogs** table. |
84 | 110 |
|
85 |
| -The following Kusto query displays the log entries of Eureka Server for Spring component logs. |
| 111 | +1. Enter the following Kusto query to display the log entries of Eureka Server for Spring component logs. |
86 | 112 |
|
87 |
| -```kusto |
88 |
| -ContainerAppSystemLogs |
89 |
| -| where ComponentType == "SpringCloudEureka" |
90 |
| -| project Time=TimeGenerated, Type=ComponentType, Component=ComponentName, Message=Log |
91 |
| -| take 100 |
92 |
| -``` |
| 113 | + ```kusto |
| 114 | + ContainerAppSystemLogs |
| 115 | + | where ComponentType == "SpringCloudEureka" |
| 116 | + | project Time=TimeGenerated, Type=ComponentType, Component=ComponentName, Message=Log |
| 117 | + | take 100 |
| 118 | + ``` |
| 119 | +
|
| 120 | +1. Select the **Run** button to run the query. |
93 | 121 |
|
94 | 122 | ::: zone-end
|
95 | 123 |
|
96 | 124 | ::: zone pivot="azure-cli"
|
97 | 125 |
|
98 |
| -Java component logs can be queried using the [Azure CLI](/cli/azure/monitor/log-analytics). |
| 126 | +You query the component logs via the Azure CLI [log analytics](/cli/azure/monitor/log-analytics) extension. |
99 | 127 |
|
100 |
| -The following example Azure CLI queries output a table containing log records for the Eureka Server for Spring component. The `project` operator's parameters specify the table columns. The `$WORKSPACE_CUSTOMER_ID` variable contains the GUID of the Log Analytics workspace. |
| 128 | +1. Run the following command to create a variable for your Log Analytics workspace ID. |
101 | 129 |
|
102 |
| -# [Bash](#tab/bash) |
| 130 | + Make sure to replace `<WORKSPACE_ID>` with your Log Analytics workspace ID before running the query. |
103 | 131 |
|
104 |
| -```azurecli |
105 |
| -az monitor log-analytics query --workspace $WORKSPACE_CUSTOMER_ID --analytics-query "ContainerAppSystemLogs | where ComponentType == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType, Component=ComponentName, Message=Log | take 5" --out table |
106 |
| -``` |
| 132 | + # [Bash](#tab/bash) |
107 | 133 |
|
108 |
| -# [PowerShell](#tab/powershell) |
| 134 | + ```azurecli |
| 135 | + SET $WORKSPACE_ID=<WORKSPACE_ID> |
| 136 | + ``` |
109 | 137 |
|
110 |
| -```powershell |
111 |
| -$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $WORKSPACE_CUSTOMER_ID -Query "ContainerAppSystemLogs | where ComponentType == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType, Component=ComponentName, Message=Log | take 5" |
112 |
| -$queryResults.Results |
113 |
| -``` |
| 138 | + # [PowerShell](#tab/powershell) |
114 | 139 |
|
115 |
| ---- |
| 140 | + ```powershell |
| 141 | + $WORKSPACE_ID = "<WORKSPACE_ID>" |
| 142 | + ``` |
| 143 | +
|
| 144 | + --- |
| 145 | +
|
| 146 | +1. Run the following command to query the logs table. |
| 147 | +
|
| 148 | + # [Bash](#tab/bash) |
| 149 | +
|
| 150 | + ```azurecli |
| 151 | + az monitor log-analytics query --workspace $WORKSPACE_CUSTOMER_ID --analytics-query "ContainerAppSystemLogs | where ComponentType == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType, Component=ComponentName, Message=Log | take 5" --out table |
| 152 | + ``` |
| 153 | +
|
| 154 | + # [PowerShell](#tab/powershell) |
| 155 | +
|
| 156 | + ```powershell |
| 157 | + $queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $WORKSPACE_ID -Query "ContainerAppSystemLogs | where ComponentType == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType, Component=ComponentName, Message=Log | take 5" |
| 158 | + $queryResults.Results |
| 159 | + ``` |
| 160 | +
|
| 161 | + --- |
| 162 | +
|
| 163 | + The `project` operator's parameters specify the table columns. |
116 | 164 |
|
117 | 165 | ::: zone-end
|
118 | 166 |
|
|
0 commit comments