Azure Log Analytics is a service that can collect logs from any resource, within Azure. Having the possibility to send custom logs, leads us seamlessly to the next point.

Sometimes there’s that need to check what’s happening during a process, logging to a text file or keeping historical logs in a SQL database is mostly used. But what if alerts need to be triggered or a report in Power BI needs to be created?

Azure Log Analytics

Log Analytics is part of Azure Monitor an is used to collect logs from Azure resources. For more information about Azure Log Analytics click this LINK

Microsoft Flow provides us following connectors, these can be used to transfer logs towards and get logs out of Log Analytics:

  • Azure Log Analytics: Get output via Kusto query
    More information can be found here
  • Azure Log Analytics Data Collector: Send custom events to the log analytics workspace.
    More information can be found here

How-To send custom log from Power App to Log Analytics?

First of all you need to have a Azure Log Analytics workspace. This will end up by having this:

Creating a file that can be used to create the custom log.
This example, gives us the possibility to create a custom log

Time,EventCode,EventType,EventComment
2019-08-27 01:34:36,100,SUCCESS,Collection has been populated
2019-08-27 01:33:33,101,ERROR,Collection has not been populated
2019-08-27 01:33:33,102,INFO,Collection has been cleared

Creating custom log can be done as followed. Open the Azure portal and select your Azure Log Analytics Workspace. Select Advanced settings, data, custom logs and click “Add +”

Choose the file that includes the sample log data.

Click “Next >”

Click “Next >”

Define a log collection paths and press the [+] – button and click “Next >”

Add name and description of the power app custom log and click “Done”

The data is visible in the Azure Log Analytics workspace, after data has been inserted. Now the custom logging can be created in the power app. In this example there is button that will retrieve user information via graph API. When the collection is empty, means that the user information has not been found.

Depending on the result a Microsoft Flow will be triggered that will send the custom log to Log Analytics. Let’s have a look at the flow.

The flow is triggered by an RUN in the power app and the following steps the variable will be populated by values from the power app. Variables will be varEventCode, varEventType and varEventDetails. Getting the current time will lead us to the final step and that’s sending the data to the custom logs in the log analytics workspace.

The connection to the workspace is build by providing the workspace id and password, that can be found at the following location:

Advanced setting >> Connected Sources >> Windows Servers >> here workspace id and primary key can be copied. Save the flow and get the user information in the power app by clicking the button.

Data has been found, means that an event OK has been created in the Azure Log Analytics. Checking this in log analytics, will gives us back this event.

This procedure gives us the opportunities to collect process logs into Log Analytics.

EXTRA: Idea has been posted at the PowerApps community: VOTE now!!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: