0

where would I get azure IoT hub metrics data?

I would like to get the metrics data on which alerts are set.I am able to find d2c messages but could not find metrics data.

GMB
  • 337
  • 2
  • 6
  • 21
  • Please read [How to ask](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Marc Estrada Jun 01 '18 at 07:28

2 Answers2

2

You can view and create custom views of your metrics via the blade of your IoT hub.You can choose to send your metrics data to an Event Hubs endpoint or an Azure Storage account by clicking Diagnostics settings.Please refer to the document about Understand IoT Hub metrics.

The metrics define the summary counts of various configuration states such as Success, In Progress, and Error. Custom metrics are specified as queries on device twin reported properties. System metrics are default metrics that measure twin update status, such as the number of device twins that are targeted and the number of twins that have been successfully updated.

Michael Xu
  • 4,382
  • 1
  • 8
  • 16
  • Yes, this is one possible way but I want to access metrics through REST api. – G KAMESWAR RAO Jun 07 '18 at 04:56
  • 1
    @GKAMESWARRAO, you can refer to this [article](https://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-rest-api-walkthrough#retrieve-metric-values).The Azure Monitor API makes it possible to programmatically retrieve the available default metric definitions, granularity, and metric values from IoT Hub resource. – Michael Xu Jun 07 '18 at 05:41
0

You can do this via Azure monitor metrics rest api.

refer this to get the metrics name from the first column. For example if you want to get connected devices connectedDeviceCount will be the metric name.

After getting the metric name, you need to form the api.

refer this to get the metric api syntax. Since we have metric name, you can use optional parameter in the get api now. Example for connectedDeviceCount:

GET https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/metrics?api-version=2018-01-01&metricnames=connectedDeviceCount

resourceUri for iotHub will look like :

IoT Hub - /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Devices/IotHubs/{iot-hub-name}

refer this for resource uri format

Don't forget to add the bearer token. you can use client credentials grant

Akash Rana
  • 114
  • 1
  • 4