Automate Azure Monitor log processes with the connector for Microsoft Flow
Microsoft Flow allows you to create automated workflows using hundreds of actions for a variety of services. Output from one action can be used as input to another allowing you to create integration between different services. The Azure Log Analytics connector for Microsoft Flow allow you to build workflows that include data retrieved by log queries from a Log Analytics workspace in Azure Monitor.
This article was recently updated to use the term Azure Monitor logs instead of Log Analytics. Log data is still stored in a Log Analytics workspace and is still collected and analyzed by the same Log Analytics service. We are updating the terminology to better reflect the role of logs in Azure Monitor. See Azure Monitor terminology changes for details.
For example, you can use Microsoft Flow to use LAzure Monitor log data in an email notification from Office 365, create a bug in Azure DevOps, or post a Slack message. You can trigger a workflow by a simple schedule or from some action in a connected service such as when a mail or a tweet is received.
The tutorial in this article shows you how to create a flow that automatically sends the results of an Azure Monitor log query by email, just one example of how you can use the Log Analytics connector in Microsoft Flow.
Step 1: Create a flow
- Sign in to Microsoft Flow, and select My Flows.
- Click + Create from blank.
Step 2: Create a trigger for your flow
- Click Search hundreds of connectors and triggers.
- Type Schedule in the search box.
- Select Schedule, and then select Schedule - Recurrence.
- In the Frequency box select Day and in the Interval box, enter 1.
Step 3: Add a Log Analytics action
- Click + New step, and then click Add an action.
- Search for Log Analytics.
- Click Azure Log Analytics – Run query and visualize results.
Step 4: Configure the Log Analytics action
Specify the details for your workspace including the Subscription ID, Resource Group, and Workspace Name.
Add the following log query to the Query window. This is only a sample query, and you can replace with any other that returns data.
Event | where EventLevelName == "Error" | where TimeGenerated > ago(1day) | summarize count() by Computer | sort by Computer
Select HTML Table for the Chart Type.
Step 5: Configure the flow to send email
Click New step, and then click + Add an action.
Search for Office 365 Outlook.
Click Office 365 Outlook – Send an email.
Specify the email address of a recipient in the To window and a subject for the email in Subject.
Click anywhere in the Body box. A Dynamic content window opens with values from previous actions.
Select Body. This is the results of the query in the Log Analytics action.
Click Show advanced options.
In the Is HTML box, select Yes.
Step 6: Save and test your flow
- In the Flow name box, add a name for your flow, and then click Create flow.
- The flow is now created and will run after a day which is the schedule you specified.
- To immediately test the flow, click Run Now and then Run flow.
- When the flow completes, check the mail of the recipient that you specified. You should have received a mail with a body similar to the following:
Send feedback about: