How to configure monitoring in Azure Digital Twins

Important

A new version of the Azure Digital Twins service has been released. In light of the new service's expanded capabilities, the original Azure Digital Twins service (described in this documentation set) has been retired.

To view the documentation for the new service, visit the active Azure Digital Twins Documentation.

Azure Digital Twins supports robust logging, monitoring, and analytics. Solutions developers can use Azure Monitor logs, diagnostic logs, activity logging, and other services to support the complex monitoring needs of an IoT app. Logging options can be combined to query or display records across several services and to provide granular logging coverage for many services.

This article summarizes logging and monitoring options and how to combine them in ways specific to Azure Digital Twins.

Note

This article was recently updated to use the term Azure Monitor logs instead of Log Analytics. Log data is still stored in a Log Analytics workspace and is still collected and analyzed by the same Log Analytics service. We are updating the terminology to better reflect the role of logs in Azure Monitor. See Azure Monitor terminology changes for details.

Review activity logs

Azure activity logs provide quick insights into subscription-level event and operation histories for each Azure service instance.

Subscription-level events include:

  • Resource creation
  • Resource removal
  • Creating app secrets
  • Integrating with other services

Activity logging for Azure Digital Twins is enabled by default and can be found through the Azure portal by:

  1. Selecting your Azure Digital Twins instance.

  2. Choosing Activity log to bring up the display panel:

    Activity log

For advanced activity logging:

  1. Select the Logs option to display the Activity Log Analytics Overview:

    Selection

  2. The Activity Log Analytics Overview summarizes essential activity log data:

    Activity log analytics overview

Tip

Use activity logs for quick insights into subscription-level events.

Enable customer diagnostic logs

Azure diagnostic settings can be set for each Azure instance to supplement activity logging. While activity logs pertain to subscription-level events, diagnostic logging provides insights into the operational history of the resources themselves.

Examples of diagnostic logging include:

  • The execution time for a user-defined function
  • The response status code of a successful API request
  • Retrieving an app key from a vault

To enable diagnostic logs for an instance:

  1. Bring up the resource in Azure portal.

  2. Select Diagnostic settings:

    Diagnostic settings one

  3. Select Turn on diagnostics to collect data (if not previously enabled).

  4. Fill in the requested fields and select how and where data will be saved:

    Diagnostic settings two

    Diagnostic logs are often saved using Azure File Storage and shared with Azure Monitor logs. Both options can be selected.

Tip

Use diagnostic logs for insights into resource operations.

Azure monitor and log analytics

IoT applications unite disparate resources, devices, locations, and data into one. Fine-grained logging provides detailed information about each specific piece, service, or component of the overall application architecture but a unified overview is often required for maintenance and debugging.

Azure Monitor includes the powerful log analytics service, which allows logging sources to be viewed and analyzed in one location. Azure Monitor is therefore highly useful for analyzing logs within sophisticated IoT apps.

Examples of use include:

  • Querying multiple diagnostic log histories
  • Seeing logs for several user-defined functions
  • Displaying logs for two or more services within a specific time-frame

Full log querying is provided through Azure Monitor logs. To set up these powerful features:

  1. Search for Log Analytics in the Azure portal.

  2. Your available Log Analytics workspace instances will be displayed. Choose one and select Logs to query:

    Log analytics

  3. If you don't already have a Log Analytics workspace instance, you can create a workspace by selecting the Add button:

    Create OMS

Once your Log Analytics workspace instance is provisioned, you may use powerful queries to find entries in multiples logs or search using specific criteria using Log Management:

Log management

For more information about powerful query operations, read getting started with queries.

Note

You may experience a 5 minute delay when sending events to Log Analytics workspace for the first time.

Azure Monitor logs also provide powerful error and alert notification services, which can be viewed by selecting Diagnose and solve problems:

Alert and error notifications

Tip

Use Log Analytics workspace to query log histories for multiple app functionalities, subscriptions, or services.

Other options

Azure Digital Twins also supports application-specific logging and security auditing. For a thorough overview of all Azure logging options available to your Azure Digital Twins instance, read the Azure log audit article.

Next steps