Forum Discussion

sarfrazkhs's avatar
sarfrazkhs
Copper Contributor
Mar 30, 2020

Log Analytics with IOTHUb

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 
     
    • sarfrazkhs's avatar
      sarfrazkhs
      Copper Contributor

      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
       

       

      • CliveWatson's avatar
        CliveWatson
        Former Employee

        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





Resources