Create CSV reports from Log Analytics queries and email using Azure Logic Apps

Creating CSV reports from Log Analytics queries and email using Azure Logic Apps can be done in a few steps using a simple Workflow design!

What are Logic Apps?

A little resource with a big outcome, Logic Apps assist you with automated workflow; scheduling, automating, composing a task or even rewriting a task. Very cost effective too!

What is Log Analytics?

A log ingestion resource tool used in Azure – data can be collected from a number of resources including Azure Monitor logs, virtual machines, Azure Kubernetes Service etc! Queries can then be ran against this data; even creating dashboards! Check out this blog on creating an Azure Dashboard

Logic Apps Workflow

I have blogged previous on how to initially create an Azure Logic App – once created; lets review the workflow

8 stages, it will take you longer to set the workflow up than for the logic app to run – they are awesome!

Lets have a quick summary of the stages!

Recurrence: You want to report to run regularly, in this I will be running mine at 8pm

Query1, Query2, Query3: Three sample queries that are ran within Log Analytics

query1

ContainerInventory
| where Computer == "aks-agentpool-22784237-vmss000000"
| where ContainerID == "0f78f21aa5d22ebcaf6b22991fc159d87a2988774375a6460e8e544c874a819c"
| where TimeGenerated <= ago(1m) 

query2

KubePodInventory
| where Computer == "aks-agentpool-22784237-vmss000000"
| where ContainerID == "0f78f21aa5d22ebcaf6b22991fc159d87a2988774375a6460e8e544c874a819c"
| where TimeGenerated <= ago(1m) 

query3

KubeNodeInventory
| where Computer == "aks-agentpool-22784237-vmss000000"
| where TimeGenerated <= ago(1m)

Create CSV table

Each contains a value reference from the respective query

Send an email

The CSV tables can be combined as one whole .csv attachment or as multiple .csv files

Awesome! Workflow setup, time to run!

Logic App workflow and creation complete!

A run is completed in a matter of seconds!

Checking your email – you will have the required attachment(s)!

Very effective , check out how an Azure Logic App can assist you!

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 )

Facebook photo

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

Connecting to %s