Wednesday, April 12, 2017

Tracked properties on Logic Apps and queries on Log Search or OMS

In our Logic App, we can add tracked properties onto different actions to track our custom data in diagnostics data.

Why we need to track properties? Because it can be very useful to search diagnostics data by custom values (e.g. The order's customer identifier).

To implement this feature, when we are editing our Logic App, we have to switch to code view. Inside the action or actions that we want to track some properties, we have to add the trackedProperties property after runAfter property and add inside all the properties that we want and their value.


          "Compose_Json_Order": {
                        "inputs": "@json(item())",
                        "runAfter": {},
                        "trackedProperties": {
                            "CustomerNumber": "@action()['inputs']['Order']['CustomerNumber']",
                            "ProductNumber": "@action()['inputs']['Order']['ProductNumber']",
                            "Quantity": "@int(action()['inputs']['Order']['Qty'])"
                        "type": "Compose"

When our Logic App is executed, we can go to Log Search or OMS and search or compute by these values. If we want to use these properties, we have to put inside the query box trackedProperty__ (e.g. trackedProperties_ProductNumber_s, trackedProperties_Quantity_d, ...)

In previous image, I searched in diagnostics data by CustomerNumber property, here is the query:

* Type=AzureDiagnostics trackedProperties_CustomerNumber_s=C0004

Also we can compute some tracked data:

In this case, I sum for each customer all the quantity in their orders:

* Type=AzureDiagnostics  | measure sum(trackedProperties_Quantity_d) as Quantity by trackedProperties_CustomerNumber_s | Where Quantity  > 0

These are a little introduction to tracked properties, but you can do more complex queries and generate some graphs in OMS.

No comments: