【问题标题】:Test Azure IotHub metrics collector in the simulator iot edge device在模拟器 iot edge 设备中测试 Azure IotHub 指标收集器
【发布时间】:2021-12-08 09:07:11
【问题描述】:

问题

用于物联网边缘设备的 Azure IotHub 指标收集器是我正在尝试实现的一个非常有趣的功能,尤其是通过 IotMessage 的选项 2,因此将带有指标数据的设备发布到云消息。因此,我阅读了有关该主题的官方文档,并在架构的一开始就陷入了困境。

上下文

在现有的 IotHub 中,我已经有一些边缘模块,所以我添加了 metrics-collector 模块,并按照文档中的建议设置路由。模块正确启动,但无法从edgeHubedgeAgent 获取日志(这是正常的,因为edgehubdev 没有启动edgeAgent 模块)。此外,当将 9600 端口暴露给本地端口时,我能够在 localhost:9600/metrics 端点中检索主机中的指标,所以我虽然可以在 MetricsEndpointsCSV 属性中设置它,但这并没有帮助。

问题

你们如何通过模拟(本地)测试和端到端指标检索? PS:我知道我仍然需要创建一些缺少的架构块(事件中心 + 功能应用程序),但指标消息尚未到达 iot hub。

来自 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

编辑 有趣的事实:它在天蓝色而不是在我的机器上工作=D

参考文献

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

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

【问题讨论】:

  • 您提到这在使用 iotedgehubdev 的 Azure VM 中有效,对吧?在您的本地机器上检查代理配置了吗? “通过设置 NO_PROXY 环境变量。”
  • 不,我的意思是当使用 iotedge 部署到边缘设备时它可以工作,我将尝试 NO_PROXY env var,它应该有什么值? true ?
  • 将 NO_PROXY 值设置为应排除的主机名的逗号分隔列表。使用模块名称作为主机名。例如:edgeHub、edgeAgent、myCustomModule。
  • 是的,但是 iotedgehubdev 不运行 edgeAgent 容器

标签: azure azure-iot-hub


【解决方案1】:

尝试在MetricsEndpointsCSV的指标收集器配置中设置以下值http://edgeHubDev:9600/metrics

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多