Introduction
In this blog, we will learn how to log messages to Azure Log Analytics workspace using MS Flow.
Prerequisite
- Log Analytics workspace should be created
- Workspace ID, primary key should be known beforehand
Steps to be used in flow
Firstly, we will create a simple MS flow log the message in Log Analytics. Please follow below steps.
- Create a flow with manual trigger.
- Click on ‘New Step’ and search for ‘Send data’ and select ‘Send Data’ action.
- Once you select the action, it will be available on the flow and will ask for the following details.
- Now in the Connection Name, you can put relevant name, which will be used while querying the logs for Log Analytics. I am putting – FlowLALogging
- In the workspace Id and Workspace key, put respective values from log analytics.
- To know the workspace id, open the log analytics and click on overview.
- To get the Workspace Key, go to advanced setting and copy primary or secondary key.
- After entering the values once you click on Create, the ‘Send Data’ action will be changed as below,
- The JSON request body should be in below format,
- [
- {
- "Action 1": "Testing LA Logging 1",
- "Action 2": "Testing LA Logging 2"
- }
- ]
-
In the custom Log Name – FlowLALogging
-
Now save the workflow and run it manually.
- Your flow should run successfully.
- Now wait for 5 minutes so that log data should be available for query.
- After 5 minutes go to Log Analytics - Log and run below command.
- FlowLALogging_CL| limit 50
‘_CL’ is the suffix added for each custom key. It stands for Custom Logging.