trace log to application insights

Ritu Raj 161 Reputation points
2022-02-02T17:09:30.737+00:00

Hi ,

What options do we have to custom trace logs to specific application insights ?

I was wondering if I can use Rest Api of app insights to do custom trace logs but I am not able to locate any api documentation on app insights operation that I can use.

Any suggestions?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

Accepted answer
  1. MikeUrnun 9,777 Reputation points Moderator
    2022-02-06T22:54:47.203+00:00

    Hello @Ritu Raj

    Thank you for confirming & providing additional info in the comments above. As I understand it, you have a workflow in Logic Apps comprising of multiple critical Steps which may be represented as Scopes and/or Actions (referred to as Steps below); and as your workflow runs, your goal is to capture these critical steps with your custom tracker data and send the data to your Application Insights.

    Upon review, I found that our official guidance & documentation on this exact question is quite scarce at the time of this writing and there isn't much available (besides the ones referenced/linked later in my answer here) on the internet - perhaps, partly due to the "newness" of the Standard tier offering of Logic Apps.

    Similar to how it was done with the Consumption tier (which required Log Analytics workspace & constructing of log queries for viewing), the specific feature designed for this type of use-case is Tracked Properties which is a custom data piece that you can correlate across all or some Steps; or bind to a specific Step, and emit to App Insights. In contrast to the Log Analytics approach, Logic Apps Standard provides built-in integration and support for Application Insights which enables monitoring experience a lot smoother & spot-on with richer application-level monitoring features.

    For your particular use-case for defining Tracked Properties, whether the critical step is defined as Scope or Action in your workflow, you may navigate to the Settings tab of each Action, and provide key/value pair custom data. And once that is done, for querying & viewing the data in App Insights, you would need to use the traces table in App Insights accompanied by WorkflowActionEnd event data. The key steps are as follows:

    1. In your locally running workflow, define custom trace data as Tracked Properties for critical steps of your workflow.
    2. In the hosts.json file, define log level, for example: {
      "version": "2.0",
      "extensionBundle": {
      "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
      "version": "[1.*, 2.0.0)"
      },
      "logging":{
      "logLevel": {
      "Host.Triggers.Workflows":"Trace"
      }
      }
      }
    3. Save & Publish your Logic Apps Standard workflow to Azure - this should create accompanying App Insights resource and automatically integrate.
    4. Run your workflow multiple times to produce event data in App Insights & wait a couple of mins so you can test
    5. Head over to App Insights resource, navigate to the Logs under Monitoring
    6. Run the following query using the traces table, "Host.Triggers.Workflows" category as well as the "WorkflowActionEnd" event: traces
      | where customDimensions["Category"] == "Host.Triggers.Workflows"
      | where customDimensions["EventName"] == "WorkflowActionEnd"
    7. From the result, locate the record that matches the specific Action you have defined the Tracked Properties as a critical step of your workflow.
    8. Expand the record & navigate: customDimensions -> prop_properties -> trackedProperties
    9. Your custom key/value data pair should be there.

    Steps 6-9 above are for testing in simplicity. For a real use-case, you might construct your own, more accurate query that suits your needs.

    For more information & broader context, please review the following resources:

    • Monitoring Logic Apps with Application Insights video by Paco de la Cruz
    • 2 parts blog posts, Azure Logic Apps Running Anywhere – Monitor with Application Insights, by Hamza Assyad:
      • Part 1: covers built integration of App Insights
      • Part 2: covers the overview & depth of various event data emitted to App Insights from Logic Apps, Tracked Properties and how to query them, Application Maps.

    I hope the info put together above is helpful and makes it a bit easier for you & others visiting here to get the tracing working according to your needs.


1 additional answer

Sort by: Most helpful
  1. Ritu Raj 161 Reputation points
    2022-02-08T08:01:06.98+00:00

    @MikeUrnun , thats for the guide on bicep and the connection.json. I did try the one from the stackoverflow answers but did not help. I will look at it again and keep you posted.

    For the app ingights thing : with app insights enabled for the standard logic app, I then wanted to view the logs like this .

    https://learn.microsoft.com/en-us/azure/logic-apps/monitor-logic-apps-log-analytics using the logic apps management from Marketplace.

    So I enabled sending diagnostics logs to LA workspace.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.