【问题标题】:How to query Azure App Insights logs using Node.JS如何使用 Node.JS 查询 Azure App Insights 日志
【发布时间】:2022-06-16 13:46:45
【问题描述】:

有一个example怎么可能查询

  • Lo​​gAnalytics 工作区 日志
  • 单个资源的指标 使用 Node.Js:

但我找不到从 AppInsights 或直接从资源中查询 日志 的选项。

我需要它来自动报告性能,所以我打算查询requests 表(我们使用https://github.com/microsoft/ApplicationInsights-Java 发送日志)。目前报告是使用 AppInsights 的性能刀片手动完成的 - 检查平均和 99 个百分位的请求与 URL 上的特定过滤器

【问题讨论】:

    标签: node.js typescript azure logging


    【解决方案1】:

    如何使用 Node.JS 查询 Azure App Insights 日志

    • 在 Azure 门户中,创建 Application Insights 实例并从概览页面复制检测密钥

    • 在 Visual Studio 代码中创建示例 NodeJS Web App
    • 我们可以在 localhost 中添加检测密钥,也可以在 nodejs 应用程序部署到 Azure 后更新一次。这里我添加了所需的应用程序洞察设置并部署了应用程序
    • server.js,添加
    let  appInsights = require('applicationinsights');
    appInsights.setup("cc580d32-a7eb-41d7-b0e0-90ea0889fd10");
    appInsights.start();
    
    • 从应用程序的根文件夹,打开终端并运行
    npm install applicationinsights --save
    

    • 将应用程序部署到 Azure
    • 浏览应用程序

    在 Application Insights 中查看日志

    • Application Insights 查询基于 KQL
    • 导航到 Azure 门户 => 你的 Application Insights 实例 => Logs 在监控下 => 点击跟踪
    使用 Node.Js 的单个资源的

    指标

    • 导航到监控下的指标

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-25
      • 1970-01-01
      • 2021-04-30
      • 2020-07-14
      • 2022-11-23
      • 2019-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多