LogicApps monitoring with Log Analytics

Azure LogicApps 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

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

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. 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

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

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

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

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

Detailed Logging and resubmit LogicApps

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

lazoomedin

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

Alerts and filters

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

logquery

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!

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s