I am currently struggling with Kusto to get the data projected in the way I need it.
I found a solution for the following example already:
print sampleData = dynamic({
"url": "/api/rest/v2/services/bacnet/remote/devices",
"status": 200,
"headers": {
"content-length": "2514",
"content-type": "application/json"
},
"body": {
"1111": {
"objects": {
"analog-inputs": {
"0": {
"units": "DegreesCelsius",
"present-value": 21.25
},
"1": {
"units": "PercentRelativeHumidity",
"present-value": 46.2
}
}
}
},
"2222": {
"objects": {
"analog-inputs": {
"0": {
"units": "DegreesCelsius",
"present-value": 22.18
},
"1": {
"units": "PercentRelativeHumidity",
"present-value": 46.7
}
}
}
}
}
})
| mv-expand kind=array l=sampleData.body
| project deviceId = tostring(l[0]), objectValue = l[1]
| mv-expand kind=array objectValue.objects
| extend inputType = tostring(objectValue_objects[0])
| mv-expand kind=array sensorReading = objectValue_objects[1]
| extend objectId = tostring(sensorReading[0]), units = tostring(sensorReading[1].units), sensorValue = sensorReading[1].['present-value']
| project-away objectValue, objectValue_objects, sensorReading
| extend twinId = strcat(deviceId, inputType, objectId)
| lookup kind=leftouter (
datatable (twinId: string, modelId:string) [
"1111analog-inputs0", "modelid123"
]
) on twinId
but I am not able to find a solution for this one:
print sampleData = dynamic({
"url": "/api/rest/v2/services/bacnet",
"status": 200,
"headers": {
"content-length": "1067",
"content-type": "application/json"
},
"body": {
"local": {
"objects": {
"devices": {
"5000": {
"object-name": "ABC-LDN-DEF-GHIJ"
},
"4194303": {
"object-name": "ABC-LDN-DEF-GHIJ"
}
},
"analog-values": {
"1": {
"units": "NoUnits",
"present-value": 0
},
"2": {
"units": "NoUnits",
"present-value": 122
}
}
}
}
}
})
The challenge for me is, to print each analog-values element as one row as did above and also add a substring(['object-name'], 4, 3) of the "object-name" of the first "devices" element to it. The reason is, that inside the object-name is the location configured (LDN) what I need.
My expected output would look like:

Can someone help me out?

Try with the below code to print
analog-valueselement as one row andlocationas LDN and also to get the required output.Output: