Get Tracked Properties In Log Analytics

1 minute read

Description:

This is how I was finally able to get tracked properties to show up in Log Analytics. These can be valuable as they allow you to store the value of variables in Log Analytics with a specific run. For example, we use it to get a process ID from a third party system that is unique to each Logic App run.

To Resolve:

  1. Inside a Logic App:

    • Create an ‘Initialize Variable’ action after you have a variable you want captured in logs.
    • Data Type string
    • Value $myvar where myvar is the variable you want to capture
    • Click on the ellipsis on the right for the ‘Initialize Variable’ action and go to Settings
      • Tracked Properties section:
      • Name: Whatever you want it to show up as in Log Analytics
      • Value: "@action().inputs.variables[0].value"
  2. Let it run a couple times and you should be able to query for it now:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    AzureDiagnostics
    | where ResourceProvider == "MICROSOFT.LOGIC"
    | where status_s <> "Running"
    | where tags_JobStream_s == "My_Logic_App"
    | where OperationName == "Microsoft.Logic/workflows/workflowActionCompleted"
    | extend ProcessID = trackedProperties_ProcessID_s
    | extend LogicApp = resource_workflowName_s
    | extend Status = status_s
    | extend StartTime = startTime_t
    | extend EndTime = endTime_t
    | extend TimeCompleted = TimeGenerated
    | extend CoorelationID = correlation_clientTrackingId_s
    | project TimeCompleted, LogicApp, Status, ProcessID, StartTime, EndTime, CoorelationID
    
  3. Pay particular attention to workflowActionCompleted. Another example where I filter on the action called Initialize-logAnalyticsProcessID from the instructions in step 1:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    
    AzureDiagnostics
    | where ResourceProvider == "MICROSOFT.LOGIC"
    | where status_s <> "Running"
    | where tags_JobStream_s == "My_Logic_App"
    | where OperationName == "Microsoft.Logic/workflows/workflowActionCompleted"
    | where resource_actionName_s == "Initialize-logAnalyticsProcessID"
    | extend ProcessID = trackedProperties_Process_ID_s
    | extend LogicApp = resource_workflowName_s
    | extend Status = status_s
    | extend StartTime = startTime_t
    | extend EndTime = endTime_t
    | extend TimeCompleted = TimeGenerated
    | extend CoorelationID = correlation_clientTrackingId_s
    | project TimeCompleted, LogicApp, Status, ProcessID, StartTime, EndTime, CoorelationID
    

Comments