azureazure-logic-appsappinsights

How can I include the trace message that triggered an Azure AppInsights alert in the payload of an email to Teams?


I am triggering an email to a Microsoft Teams channel with an alert when a message to the Azure AppInsights traces table has a severity level of 3. I would like to be able to see the actual log message that triggered the alert.

I have read that I need to write a Logic App. But I have been unable to figure out how to get the actual log message from there.

Has anyone else done this? Are there any samples that anyone is aware of?


Solution

  • You can send Messages of Log using below design:

    enter image description here

    In alert, you will see condition , in the same way you can use this as a condition.

    To run KQL query you need to send logs data to KQL clusters and then you can run KQL queries on logs from ADX Cluster. Now you can use the Output of the KQL query in Next HTTP Request to send messages to Teams Channel. To send messages to teams you need to create a incoming webhook.

    enter image description here

    Output:

    enter image description here

    Output in Teams channel

    enter image description here

    You can also send any output like below:

    enter image description here

    In place of outputs('Compose') you need to use like this :

    enter image description here

    Then:

    enter image description here

    In place of http trigger you need to use Recurrence trigger running for every second to check the condition for kql, this is how you can create alert in Logic apps with kql output.