Publishing Custom Queries of Logic Apps Execution Logs

07 December, 2017 by Paco de la Cruz

In a previous post, I showed how to implement Business Activity Monitoring for Logic Apps. However, sometimes developers, ops, or business users want to query execution logs to get information about the processing of business messages. Whether for troubleshooting or auditing, there are some questions these personas might have, like:

  • When was a business document processed?
  • What was the content of a received document?
  • How was that message processed?

As we saw in that post, we can send diagnostic log information and custom tracked properties to Azure Log Analytics. We also saw how easy is to query those logs to get information about Logic Apps execution and messages processed. Now the question is, how can we publish those custom queries, so different users can make use of them? In this post, I’ll show one easy way to do that.

1. Tracking the relevant custom properties and sending data to Log Analytics.

The first thing to do is to track the relevant custom properties we need for our queries as tracked properties in our Logic App workflow. Then you need to configure the Logic App workflow to send diagnostics information to Azure Log Analytics. You can follow the instructions on my previous post to perform those steps.

2. Creating the queries to get the information our users need

Once the information is being logged on Log Analytics, we need to create the queries to give the users the information they need. For that, first we need to open the Azure Log Analytics Portal. To open the portal we need to

  • Go to the Log Analytics Resource on the Azure Portal
  • Go to Log Search
  • Click on Analytics

And now you are ready to create your own queries.

20 Open Log Analytics.gif

Based on the tracked properties of the Logic App workflow shown in my previous post, I wrote this query to get all orders processed in the time range selected. This query returns, order number, total, date, channel, customer Id, the name of the Logic App workflow which processed this message, and the workflow run id. These last 2 columns would be quite handy for troubleshooting.

21a Query and Results.png

3. Saving the custom Azure Log Analytics query

Once we have the query ready, we can save it and export it, so later we can publish it. To do that, we follow the steps below

  • Click the Save button
  • Give a name and category to the query. The category is quite useful for searching among all saved queries.
  • Then we click the Export button
  • And select the Share a Link to Query option, so the link to the query is saved in the clipboard.

21 Save and Export Query.gif

4. Publishing the custom Azure Log Analytics query to the users

After we have gotten the link to the query, we can publish it in the same Dashboard we created for our BAM charts described in my previous post. We need to: 

  • Edit the shared Azure Dasboard
  • Add the Markdown tile.
  • Add the markdown text which contains the link to the query created above.

Now the users will have all the charts and custom queries they need in one single place!

22 Add Query to Dashboard.gif

Making easier to users to get to the workflow run logs of a particular business message on Logic Apps.

Logic Apps provide a very detailed view of the execution of the workflows. However, I’ve been asked so many times to make easier to users to get the run details of a particular business message. Here is a tip on how to do it.

  • First, we need to create a query to get the runId of the workflow instance that processed the message. I created this query to get those details for the orders submitted by a particular user.
  • Once we have that query, we publish it to the same markdown tile in our dashboard.
  • We also add the link to the Logic App workflow Azure resource to the same dashboard tile.

Now users can query the orders submitted by a user, get the workflow run id, and get the workflow run details in very few clicks. Quite handy! :)

23 Query Logic App Instance by Business Id.gif

Wrapping-up

10 Whole Dashboard.png

In this post, we’ve seen how to create and publish custom queries of Logic Apps execution logs. We’ve also seen how to make easier to users to get the workflow run details of the processing of a particular business message. Now you should be ready to start creating and publishing your own custom queries and creating amazing monitoring and tracking dashboards for your Logic Apps solutions.

I hope you’ve got some useful tips from this post and you’ve enjoyed it. Feel free to leave your questions or comments below,

Cross-posted on Paco’s Blog. Follow Paco on @pacodelacruz.

Latest Posts