LogicApps monitoring with Log Analytics
Tags: azure, serverless
Published: 2019-09-12 20:10:33

---
title: LogicApps monitoring with Log Analytics
published: true
tags: Azure,Serverless
canonical_url: https://peterrombouts.nl/2019/04/01/logicapps-monitoring-with-log-analytics/
---

Azure [LogicApps](https://azure.microsoft.com/en-us/services/logic-apps/) are incredibly powerful and I believe it should be in every developers toolbox. Enterprise integrations, ready-to-use connectors and all of this with almost no code and serverless!

Alas monitoring and debugging are more complex. In this blog I will explain how to add LogicApps to Log Analytics, and even track custom properties for filtering and alerting. Keep on reading for the exciting stuff!

## Create a LogicApp

Let’s start out with a very simple LogicApp. This app will receive a HTTP request with an array of data, and for each item, send an email:

![LogicAppDesigner](https://peterrombouts.files.wordpress.com/2019/04/logicappdesigner.png?w=840)

## Standard logging

The history of runs is shown below. You can drill down and see the actual results of each call, and see what part took how long and more details.

![LogicAppHistory](https://peterrombouts.files.wordpress.com/2019/04/logicapphistory.png?w=840)

## Enter the Log Analytics workspace

Standard logging seems fine, but what if you want to integrate this LogicApp and have alerting setup? First of all, setup a [Log Analytics workspace](https://docs.microsoft.com/en-us/azure/azure-monitor/learn/quick-create-workspace). When you created the Log Analytics Workspace, make sure your LogicApp sends logs to it. You can simply go to the Logs section of your LogicApp:

![logicapplogs](https://peterrombouts.files.wordpress.com/2019/04/logicapplogs.png?w=840)

As you can see, I already set mine up to the existing one. When that is done, you can click on the Log Analytics workspace, which brings up the **overview** blade of your workspace:

![laworkspace](https://peterrombouts.files.wordpress.com/2019/04/laworkspace.png?w=840)

Clicking on ‘View solutions’ on the ‘Configure monitoring solutions’ will open up the settings. Click on ‘Add’ and search for **Logic Apps Management**. Please note that this is in **preview** at the moment of writing:

![lamanagement](https://peterrombouts.files.wordpress.com/2019/04/lamanagement.png?w=840)

If you select **Create** and choose the correct settings, it will show the runs and logging in the **Workspace Summary** section of Log Analytics:

![laoverview](https://peterrombouts.files.wordpress.com/2019/04/laoverview-1.png?w=840)

As you can see, we see a nice chart with basic info. Drill down on that and you will see all LogicApps reporting to this workspace. Note that I’ve only configured one:

![lalogs](https://peterrombouts.files.wordpress.com/2019/04/lalogs.png?w=840)

## Detailed Logging and resubmit LogicApps

If we zoom in even further we can rerun several LogicApps and view more detailed information:

![lazoomedin](https://peterrombouts.files.wordpress.com/2019/04/lazoomedin.png?w=840)

Here we can click on Logs and zoom in even further, or we can resubmit multiple LogicApps.

## Tracking custom properties

Let’s say we have many, many events coming in, and we want to track by CustomerID. For the LogicApp, we have to define tracked properties. For this go back to the LogicApp, enter Code view, and add the properties you want to track:

```
"runAfter": {}, "trackedProperties": { "CustomerId": "@{items('For\_each')?['data']?['customerid']}", "Flow": "Email", "Receiver": "SomeReceiver", "Subject": "@{items('For\_each')['subject']}" }
```

To explain the piece of code above; I’ve added the ‘trackedProperties’ in the forEach loop, and this will send these custom properties to Log Analytics. Obviously these properties correspond to the event we got in the HTTP Request.

After running this app now, we can see tracked properties in Log Analytics! If we click on the ‘ **View** ‘ button, it will bring up the actual properties:

![latracking](https://peterrombouts.files.wordpress.com/2019/04/latracking.png?w=840)

## Alerts and filters

Now for the advanced scenario, we want to create a query and search on the properties:

![logquery](https://peterrombouts.files.wordpress.com/2019/04/logquery.png?w=840)

In the above sample, you can see that a simple filter on schema will bring up all tracked properties and on the right, you can see a simple query to retrieve all events for ‘ **Customer 1** ‘. That is basically it! Now you can click on ‘ **Create Alert Rule** ‘ and do your magic there, and create alerts using these tracked properties!

## Conclusion

Setting up the LogicApps to communicate with Log Analytics is a breeze (yes still preview) with the Logic Apps Management module. Tracking properties is a bit of manual labour, because you have to enter code view, but still no worries there. Do look out; if you add the tracked properties in the wrong portion of the JSON, you will not see anything working. And also don’t forget that it can take some time before all logs are updates. Happy low-coding!