Log Analytics with IOTHUb

Copper Contributor

Hi Members,

         I am in the process of fetching the distinct devices which are sending the data from log analytics but not quite getting the query to work as I know some syntax I am missing it.

 

AzureDiagnostics
|distinct (properties_s.deviceId)
| where ResourceType == "IOTHUBS"
| extend properties=parse_json(properties_s)
| extend deviceid=properties.deviceId
 
Thanks & Regards,
SSK
3 Replies

@sarfrazkhs 

 

AzureDiagnostics
| where ResourceType == "IOTHUBS"
| distinct _ResourceId
 
Replace _ResourceId with a working column 
 

Thanks @CliveWatson 

 

I used the query as per the one but would like to know how can I get deviceId in the query.

 

AzureDiagnostics
| where ResourceType == "IOTHUBS"
| distinct properties_s
 

sarfrazkhs_0-1585645345239.png

 

@sarfrazkhs 

 

I don't have that data, but these are a near example:

 

AzureActivity
| extend clientRequestId_ = tostring(parse_json(HTTPRequest).clientRequestId) 
| distinct clientRequestId_


AzureActivity
| extend clientRequestId_ = tostring(parse_json(HTTPRequest).clientRequestId) 
| summarize count() by clientRequestId_

 Go to Log Analytics and run query

 

You can press the "..." to extend the data into a column

Annotation 2020-03-31 160937.jpg