Mehdi Benmoha
Mehdi Benmoha

Reputation: 3945

Test Azure IotHub metrics collector in the simulator iot edge device

Problem

Azure IotHub metrics collector for Iot edge devices a very interesting feature that I am trying to implement and especially the option 2 that goes through IotMessage, so publishing a Device to Cloud message with the metrics data. So, I read the official documentation about the subject, and I got stuck at the very beginning in the architecture.

Context

In an existing IotHub, I already have some edge modules, so I added the metrics-collector module, and set up the routing as suggested in the documentation. The module starts correctly but can't fetch logs from edgeHub nor from edgeAgent (which is normal because edgehubdev doesn't start an edgeAgent module). Also, when exposing the 9600 port to a local port I was able to retrieve the metrics in my host machine in the localhost:9600/metrics endpoint, so I though I could set it up in the MetricsEndpointsCSV property but that doesn't help.

Question

How do you guys manage to test and end-to-end metrics retrieval through the simular (locally) ? PS: I know that there are still some missing architecture blocks that I need to create ( event hub + function apps ), but the metrics messages are not yet arriving to iot hub.

logs from edgeHubDev

metricsCollector       | [2021-11-08 14:47:03.044 INF] Starting periodic operation Scrape and Upload Metrics...
metricsCollector       | [2021-11-08 14:47:03.045 INF] Scraping endpoint http://127.0.0.1:9600/metrics
metricsCollector       | [2021-11-08 14:47:03.046 ERR] Error scraping endpoint http://127.0.0.1:9600/metrics - System.Net.Http.HttpRequestException: Connection refused
metricsCollector       |  ---> System.Net.Sockets.SocketException (111): Connection refused
metricsCollector       |    at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
metricsCollector       |    --- End of inner exception stack trace ---
metricsCollector       |    at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
metricsCollector       |    at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
metricsCollector       |    at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
metricsCollector       |    at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
metricsCollector       |    at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
metricsCollector       |    at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
metricsCollector       |    at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
metricsCollector       |    at Microsoft.Azure.Devices.Edge.Azure.Monitor.MetricsScraper.ScrapeEndpoint(String endpoint, CancellationToken cancellationToken) in /mnt/vss/_work/1/s/edge-modules/azure-monitor/src/MetricsScraper.cs:line 72

EDIT Fun Fact: It works in azure not in my machine =D

References

Documentation: https://learn.microsoft.com/en-gb/azure/iot-edge/how-to-collect-and-transport-metrics?view=iotedge-2020-11&tabs=iothub#next-steps

Azure sample: https://github.com/Azure-Samples/iotedge-logging-and-monitoring-solution

Upvotes: 0

Views: 476

Answers (1)

Venkat Yalla
Venkat Yalla

Reputation: 558

Try setting the following value http://edgeHubDev:9600/metrics in the metrics collector configuration for MetricsEndpointsCSV

Upvotes: 2

Related Questions