Muokkaa

Jaa


Analyze logs with Elastic (ELK) using diagnostics settings

Note

The Basic, Standard, and Enterprise plans will be deprecated starting from mid-March, 2025, with a 3 year retirement period. We recommend transitioning to Azure Container Apps. For more information, see the Azure Spring Apps retirement announcement.

The Standard consumption and dedicated plan will be deprecated starting September 30, 2024, with a complete shutdown after six months. We recommend transitioning to Azure Container Apps. For more information, see Migrate Azure Spring Apps Standard consumption and dedicated plan to Azure Container Apps.

This article applies to: ✅ Java ✅ C#

This article applies to: ✅ Basic/Standard ✅ Enterprise

This article shows you how to use the diagnostics functionality of Azure Spring Apps to analyze logs with Elastic (ELK).

The following video introduces unified observability for Spring Boot applications using Elastic.


Configure diagnostics settings

To configure diagnostics settings, use the following steps:

  1. In the Azure portal, go to your Azure Spring Apps instance.
  2. Select diagnostics settings option, then select Add diagnostics setting.
  3. Enter a name for the setting, choose Send to partner solution, then select Elastic and an Elastic deployment where you want to send the logs.
  4. Select Save.

Screenshot of the Azure portal that shows the Diagnostic setting page with selected options and the name specified for the setting.

Note

There might be a gap of up to 15 minutes between when logs are emitted and when they appear in your Elastic deployment. If the Azure Spring Apps instance is deleted or moved, the operation won't cascade to the diagnostics settings resources. You have to manually delete the diagnostics settings resources before you perform the operation against its parent, the Azure Spring Apps instance. Otherwise, if you provision a new Azure Spring Apps instance with the same resource ID as the deleted one, or if you move the Azure Spring Apps instance back, the previous diagnostics settings resources will continue to extend it.

Analyze the logs with Elastic

To learn more about deploying Elastic on Azure, see How to deploy and manage Elastic on Microsoft Azure.

Use the following steps to analyze the logs:

  1. From the Elastic deployment overview page in the Azure portal, open Kibana.

    Screenshot of the Azure portal that shows the Elasticsearch (Elastic Cloud) page with the Deployment URL Kibana link highlighted.

  2. In Kibana, in the Search bar at top, type Spring Cloud type:dashboard.

    Screenshot of Elastic / Kibana that shows the search results for Spring Cloud type:dashboard.

  3. Select [Logs Azure] Azure Spring Apps logs Overview from the results.

    Screenshot of Elastic / Kibana that shows the Azure Spring Apps Application Console Logs.

  4. Search on out-of-the-box Azure Spring Apps dashboards by using the queries such as the following:

    azure.springcloudlogs.properties.app_name : "visits-service"
    

Analyze the logs with Kibana Query Language in Discover

Application logs provide critical information and verbose logs about your application's health, performance, and more. Use the following steps to analyze the logs:

  1. In Kibana, in the Search bar at top, type Discover, then select the result.

    Screenshot of Elastic / Kibana  that shows the search results for Discover.

  2. In the Discover app, select the logs- index pattern if it's not already selected.

    Screenshot of Elastic / Kibana that shows the logs page in the Discover app.

  3. Use queries such as the ones in the following sections to help you understand your application's current and past states.

For more information about different queries, see Guide to Kibana Query Language.

Show all logs from Azure Spring Apps

To review a list of application logs from Azure Spring Apps, sorted by time with the most recent logs shown first, run the following query in the Search box:

azure_log_forwarder.resource_type : "Microsoft.AppPlatform/Spring"

Screenshot of Elastic / Kibana that shows the Discover app with all logs displayed.

Show specific log types from Azure Spring Apps

To review a list of application logs from Azure Spring Apps, sorted by time with the most recent logs shown first, run the following query in the Search box:

azure.springcloudlogs.category : "ApplicationConsole"

Screenshot of Elastic / Kibana that shows the Discover app with specific logs displayed.

Show log entries containing errors or exceptions

To review unsorted log entries that mention an error or exception, run the following query:

azure_log_forwarder.resource_type : "Microsoft.AppPlatform/Spring" and (log.level : "ERROR" or log.level : "EXCEPTION")

Screenshot of Elastic / Kibana that shows the Discover app with error and exception logs displayed.

The Kibana Query Language helps you form queries by providing autocomplete and suggestions to help you gain insights from the logs. Use your query to find errors, or modify the query terms to find specific error codes or exceptions.

Show log entries from a specific service

To review log entries that are generated by a specific service, run the following query:

azure.springcloudlogs.properties.service_name : "sa-petclinic-service"

Screenshot of Elastic / Kibana that shows the Discover app with specific-service logs displayed.

Show Config Server logs containing warnings or errors

To review logs from Config Server, run the following query:

azure.springcloudlogs.properties.type : "ConfigServer" and (log.level : "ERROR" or log.level : "WARN")

Screenshot of Elastic / Kibana that shows the Discover app with Config Server logs displayed.

Show Service Registry logs

To review logs from Service Registry, run the following query:

azure.springcloudlogs.properties.type : "ServiceRegistry"

Screenshot of Elastic / Kibana that shows the Discover app with Service Registry logs displayed.

Visualizing logs from Azure Spring Apps with Elastic

Kibana allows you to visualize data with Dashboards and a rich ecosystem of visualizations. For more information, see Dashboard and Visualization.

Use the following steps to show the various log levels in your logs so you can assess the overall health of the services.

  1. From the available fields list on left in Discover, search for log.level in the search box under the logs- index pattern.

  2. Select the log.level field. From the floating informational panel about log.level, select Visualize.

    Screenshot of Elastic / Kibana that shows the Discover app with log levels displayed.

  3. From here, you can choose to add more data from the left pane, or choose from multiple suggestions how you would like to visualize your data.

    Screenshot of Elastic / Kibana that shows the Discover app with visualization options.

Next steps