Analyze logs with Elastic (ELK) using diagnostics settings

Note

Azure Spring Apps is the new name for the Azure Spring Cloud service. Although the service has a new name, you'll see the old name in some places for a while as we work to update assets such as screenshots, videos, and diagrams.

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 Azure portal showing 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 Azure portal showing 'Elasticsearch (Elastic Cloud)' page with Deployment U R L / Kibana highlighted.

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

    Elastic / Kibana screenshot showing 'Spring Cloud type:dashboard' search results.

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

    Elastic / Kibana screenshot showing 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.

    Elastic / Kibana screenshot showing 'Discover' search results.

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

    Elastic / Kibana screenshot showing logs 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"

Elastic / Kibana screenshot showing 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"

Elastic / Kibana screenshot showing 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")

Elastic / Kibana screenshot showing 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"

Elastic / Kibana screenshot showing 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")

Elastic / Kibana screenshot showing 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"

Elastic / Kibana screenshot showing 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.

    Elastic / Kibana screenshot showing Discover app showing log levels.

  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.

    Elastic / Kibana screenshot showing Discover app showing visualization options.

Next steps