Skip to content

Files

Latest commit

 

History

History
289 lines (190 loc) · 16.5 KB

monitor-logic-apps-log-analytics.md

File metadata and controls

289 lines (190 loc) · 16.5 KB
title description services ms.suite ms.reviewer ms.topic ms.date
Monitor logic apps with Azure Monitor logs
Troubleshoot logic apps using Azure Monitor logs and collecting diagnostics data for Azure Logic Apps.
logic-apps
integration
divswa, azla
how-to
03/14/2022

Set up Azure Monitor logs and collect diagnostics data for Azure Logic Apps

Note

This article applies only to Consumption logic apps. For information about monitoring Standard logic apps, review Enable or open Application Insights after deployment for Standard logic apps.

To get richer debugging information about your logic apps during runtime, you can set up and use Azure Monitor logs to record and store information about runtime data and events, such as trigger events, run events, and action events in a Log Analytics workspace. Azure Monitor helps you monitor your cloud and on-premises environments so that you can more easily maintain their availability and performance. By using Azure Monitor logs, you can create log queries that help you collect and review this information. You can also use this diagnostics data with other Azure services, such as Azure Storage and Azure Event Hubs.

To set up logging for your logic app, you can enable Log Analytics when you create your logic app, or you can install the Logic Apps Management solution in your Log Analytics workspace for existing logic apps. This solution provides aggregated information for your logic app runs and includes specific details such as status, execution time, resubmission status, and correlation IDs. Then, to enable logging and creating queries for this information, set up Azure Monitor logs.

This article shows how to enable Log Analytics on new logic apps and existing logic apps, how to install and set up the Logic Apps Management solution, and how to set up and create queries for Azure Monitor logs.

Prerequisites

Enable Log Analytics for new logic apps

You can turn on Log Analytics when you create your logic app.

  1. In the Azure portal, on the Create Logic App pane where you provide the information to create your Consumption plan-based logic app, follow these steps:

    1. Under Enable log analytics, select Yes.

    2. From the Log Analytics workspace list, select the workspace where you want to send the data from your logic app runs.

      Provide logic app information

  2. Finish creating your logic app. When you're done, your logic app is associated with your Log Analytics workspace. This step also automatically installs the Logic Apps Management solution in your workspace.

  3. After you run your logic app, to view your logic app runs, continue with these steps.

Install Logic Apps Management solution

If you turned on Log Analytics when you created your logic app, skip this step. You already have the Logic Apps Management solution installed in your Log Analytics workspace.

  1. In the Azure portal's search box, enter log analytics workspaces. Select Log Analytics workspaces.

    Select "Log Analytics workspaces"

  2. Under Log Analytics workspaces, select your workspace.

    Select your Log Analytics workspace

  3. On the Overview pane, under Get started with Log Analytics > Configure monitoring solutions, select View solutions.

    On overview pane, select "View solutions"

  4. Under Overview, select Add.

    On overview pane, add new solution

  5. After the Marketplace opens, in the search box, enter logic apps management. Select Logic Apps Management.

    From Marketplace, select "Logic Apps Management"

  6. On the Logic Apps Management tile, from the Create list, select Logic Apps Management.

    Select "Create" to add "Logic Apps Management" solution

  7. On the Create Logic Apps Management (Preview) Solution pane, select the Log Analytics workspace where you want to install the solution. Select Review + create, review your information, and select Create.

    Select "Create" for "Logic Apps Management"

    After Azure deploys the solution to the Azure resource group that contains your Log Analytics workspace, the solution appears on your workspace summary pane under Overview.

    Screenshot showing workspace summary pane with Logic Apps Management solution.

Set up Azure Monitor logs

When you store information about runtime events and data in Azure Monitor logs, you can create log queries that help you find and review this information.

Note

After you enable diagnostics settings, diagnostics data might not flow for up to 30 minutes to the logs at the specified destination, such as Log Analytics, event hub, or storage account. This delay means that diagnostics data from this time period might not exist for you to review. Completed events and tracked properties might not appear in your Log Analytics workspace for 10-15 minutes.

  1. In the Azure portal, find and select your logic app.

  2. On your logic app menu, under Monitoring, select Diagnostic settings > Add diagnostic setting.

    Under "Monitoring", select "Diagnostic settings" > "Add diagnostic setting"

  3. To create the setting, follow these steps:

    1. For Diagnostic setting name, provide a name for the setting.

    2. Under Destination details, select Send to Log Analytics workspace.

    3. For Subscription, select the Azure subscription that's associated with your Log Analytics workspace.

    4. For Log Analytics workspace, select your workspace.

    5. Under Logs > Categories, select WorkflowRuntime, which specifies the event category that you want to record.

    6. Under Metrics, select AllMetrics.

    7. When you're done, select Save.

    When you're done, your version looks similar to the following example:

    Select Log Analytics workspace and data for logging

View logic app runs status

After your logic app runs, you can view the data about those runs in your Log Analytics workspace.

  1. In the Azure portal, find and open your Log Analytics workspace.

  2. On your workspace menu, under General, select Workspace summary > Logic Apps Management.

    [!NOTE] If the Logic Apps Management tile doesn't immediately show results after a run, try selecting Refresh or wait for a short time before trying again.

    Logic app run status and count

    Here, your logic app runs are grouped by name or by execution status. This page also shows details about failures in actions or triggers for the logic app runs.

    Status summary for your logic app runs

  3. To view all the runs for a specific logic app or status, select the row for that logic app or status.

    Here is an example that shows all the runs for a specific logic app:

    View logic app runs and status

    For actions where you set up tracked properties, you can also view those properties by selecting View in the Tracked Properties column. To search the tracked properties, use the column filter.

    View tracked properties for a logic app

  4. To filter your results, you can perform both client-side and server-side filtering.

    • Client-side filter: For each column, select the filters that you want, for example:

      Example column filters

    • Server-side filter: To select a specific time window or to limit the number of runs that appear, use the scope control at the top of the page. By default, only 1,000 records appear at a time.

      Change the time window

  5. To view all the actions and their details for a specific run, select the row for a logic app run.

    Here is an example that shows all the actions and triggers for a specific logic app run:

    View actions for a logic app run

Send diagnostic data to Azure Storage and Azure Event Hubs

Along with Azure Monitor logs, you can extend how you use your logic app's diagnostic data with other Azure services, for example:

You can then get real-time monitoring by using telemetry and analytics from other services, like Azure Stream Analytics and Power BI. For example:

Based on the locations where you want to send diagnostic data, make sure that you first create an Azure storage account or create an Azure event hub. You can then select the destinations where you want to send that data. Retention periods apply only when you use a storage account.

Send data to Azure storage account or event hub

Azure Monitor diagnostics events

Each diagnostic event has details about your logic app and that event, for example, the status, start time, end time, and so on. To programmatically set up monitoring, tracking, and logging, you can use this information with the REST API for Azure Logic Apps and the REST API for Azure Monitor. You can also use the clientTrackingId and trackedProperties properties, which appear in

  • clientTrackingId: If not provided, Azure automatically generates this ID and correlates events across a logic app run, including any nested workflows that are called from the logic app. You can manually specify this ID in a trigger by passing a x-ms-client-tracking-id header with your custom ID value in the trigger request. You can use a request trigger, HTTP trigger, or webhook trigger.

  • trackedProperties: To track inputs or outputs in diagnostics data, you can add a trackedProperties section to an action either by using the Logic App Designer or directly in your logic app's JSON definition. Tracked properties can track only a single action's inputs and outputs, but you can use the correlation properties of events to correlate across actions in a run. To track more than one property, one or more properties, add the trackedProperties section and the properties that you want to the action definition.

    Here's an example that shows how the Initialize variable action definition includes tracked properties from the action's input where the input is an array, not a record.

    {
       "Initialize_variable": {
          "type": "InitializeVariable",
          "inputs": {
             "variables": [
                {
                   "name": "ConnectorName", 
                   "type": "String", 
                   "value": "SFTP-SSH" 
                }
             ]
          },
          "runAfter": {},
          "trackedProperties": { 
             "myTrackedPropertyName": "@action().inputs.variables[0].value"
          }
       }
    }

    This example shows multiple tracked properties:

    "HTTP": {
       "type": "Http",
       "inputs": {
          "body": "@triggerBody()",
          "headers": {
             "Content-Type": "application/json"
          },
          "method": "POST",
          "uri": "http://store.fabrikam.com",
       },
       "runAfter": {},
       "trackedProperties": {
          "myActionHTTPStatusCode": "@action()['outputs']['statusCode']",
          "myActionHTTPValue": "@action()['outputs']['body']['<content>']",
          "transactionId": "@action()['inputs']['body']['<content>']"
       }
    }

This example shows how the ActionCompleted event includes the clientTrackingId and trackedProperties attributes:

{
   "time": "2016-07-09T17:09:54.4773148Z",
   "workflowId": "/subscriptions/XXXXXXXXXXXXXXX/resourceGroups/MyResourceGroup/providers/Microsoft.Logic/workflows/MyLogicApp",
   "resourceId": "/subscriptions/<subscription-ID>/resourceGroups/MyResourceGroup/providers/Microsoft.Logic/workflows/MyLogicApp/runs/<run-ID>/actions/Http",
   "category": "WorkflowRuntime",
   "level": "Information",
   "operationName": "Microsoft.Logic/workflows/workflowActionCompleted",
   "properties": {
      "$schema": "2016-06-01",
      "startTime": "2016-07-09T17:09:53.4336305Z",
      "endTime": "2016-07-09T17:09:53.5430281Z",
      "status": "Succeeded",
      "code": "OK",
      "resource": {
         "subscriptionId": "<subscription-ID>",
         "resourceGroupName": "MyResourceGroup",
         "workflowId": "<logic-app-workflow-ID>",
         "workflowName": "MyLogicApp",
         "runId": "08587361146922712057",
         "location": "westus",
         "actionName": "Http"
      },
      "correlation": {
         "actionTrackingId": "e1931543-906d-4d1d-baed-dee72ddf1047",
         "clientTrackingId": "<my-custom-tracking-ID>"
      },
      "trackedProperties": {
         "myTrackedPropertyName": "<value>"
      }
   }
}

Next steps