问题描述

在使用App Service或者Kubernetes等服务时,需要收集一些日志数据并且发送到Application Insights中,当使用SDK或者是服务自带的Application Insights配置时遇见问题,有没有快速的调试方式能验证App Service是否与Application Insights之间的连通性呢?

问题解答

可以使用CURL发送请求到Application Insigths的Ingress Endpoint来验证当前环境是否可以成功发送请求!

根据参考文档(用于发送可用性测试结果的 Curl 命令)中介绍,使用 curl 发送 REST 请求,引入终结点主机名、 iKey 值和 time 值。 Application Insights 引入终结点不接受任何超过 48 小时的记录。

###适用于 Linux/MacOS 的 Curl 命令:
curl -H "Content-Type: application/json" -X POST -d '{"data":{"baseData":{"ver":2,"id":"SampleRunId","name":"MicrosoftSupportSampleWebtestResultUsingCurl","duration":"00.00:00:10","success":true,"runLocation":"RegionName","message":"SampleWebtestResult","properties":{"SampleProperty":"SampleValue"}},"baseType":"AvailabilityData"},"ver":1,"name":"Microsoft.ApplicationInsights.Metric","time":"2024-01-08T12:57:25.0000000Z","sampleRate":100,"iKey":"########-####-####-####-############","flags":0}'  https://chinanorth3-0.in.applicationinsights.azure.cn/v2/track   -v

### 适用于 Windows 的 Curl 命令:
curl -H "Content-Type: application/json" -X POST -d {\"data\":{\"baseData\":{\"ver\":2,\"id\":\"SampleRunId\",\"name\":\"MicrosoftSupportSampleWebtestResultUsingCurl\",\"duration\":\"00.00:00:10\",\"success\":true,\"runLocation\":\"RegionName\",\"message\":\"SampleWebtestResult\",\"properties\":{\"SampleProperty\":\"SampleValue\"}},\"baseType\":\"AvailabilityData\"},\"ver\":1,\"name\":\"Microsoft.ApplicationInsights.Metric\",\"time\":\"2024-01-08T12:57:25.0000000Z\",\"sampleRate\":100,\"iKey\":\"########-####-####-####-############\",\"flags\":0} https://chinanorth3-0.in.applicationinsights.azure.cn/v2/track   -v

在以上内容中,需要修改的内容有

  • time: 修改为发送请求的当前时间点,如2024-01-08T12:57:25.0000000Z
  • iKey :  在Application Insights的Overview页面中,复制 Instrumentation Key 的值
  • Application Insights的终结点,https://dc.applicationinsights.azure.com/v2/track 为global azure的终结点,如果使用的是中国区的Application Insights,需要从连接字符串中提取Ingress Endpoint,完成的值为:
    • 中国东部2区:https://chinaeast2-0.in.applicationinsights.azure.cn/v2/track
    • 中国北部3区:https://chinanorth3-0.in.applicationinsights.azure.cn/v2/track

下图为在App Service Kudu中的测试和验证过程:

第一步:准备 curl 命令并进入App Service Kudu站点:

C:\home>curl -H "Content-Type: application/json" -X POST -d {\"data\":{\"baseData\":{\"ver\":2,\"id\":\"SampleRunId\",\"name\":\"MicrosoftSupportSampleWebtestResultUsingCurl\",\"duration\":\"00.00:00:10\",\"success\":true,\"runLocation\":\"RegionName\",\"message\":\"SampleWebtestResult\",\"properties\":{\"SampleProperty\":\"SampleValue\"}},\"baseType\":\"AvailabilityData\"},\"ver\":1,\"name\":\"Microsoft.ApplicationInsights.Metric\",\"time\":\"2024-01-08T13:09:00.0000000Z\",\"sampleRate\":100,\"iKey\":\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\"flags\":0} https://chinanorth3-0.in.applicationinsights.azure.cn/v2/track

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload Upload Total Spent Left Speed
100 493 100 49 100 444 436 3956 --:--:-- --:--:-- --:--:-- 5358 {"itemsReceived":1,"itemsAccepted":1,"errors":[]}

第二步:在Application Insights中验证数据是否发送成功

进入Application Insights的Logs页面,直接查看 availabilityResults 表中最近1小时的数据:

参考资料

【Application Insights】使用CURL命令向Application Insgihts发送测试数据的更多相关文章

  1. 【应用程序见解 Application Insights】使用Azure Monitor Application Insights Agent获取Azure VM中监控数据及IIS请求指标等信息

    问题情形 为了使用Application Insights也可以监控Azure VM中的相关性能数据,如CPU, Memory,IIS Reuqest等信息,可以在VM中开始一个一个扩展插件: Azu ...

  2. 【应用程序见解 Application Insights】Application Insights 使用 Application Maps 构建请求链路视图

    Applicaotn  Insigths 使用 Application Maps 构建请求链路视图 构建系统时,请求的逻辑操作大多数情况下都需要在不同的服务,或接口中完成整个请求链路.一个请求可以经历 ...

  3. 【Azure 应用程序见解】Application Insights Java Agent 3.1.0的使用实验,通过修改单个URL的采样率来减少请求及依赖项的数据采集

    问题描述 近日好消息,如果是一个Java Spring Cloud的项目,想使用Azure Applicaiton Insights来收集日志及一些应用程序见解.但是有不愿意集成SDK来修改代码或者配 ...

  4. 使用Application Insights 做分析

    Application Insights on Windows Desktop apps, services and worker roles : https://azure.microsoft.co ...

  5. 关于Application Insights遥测功能使用【遇到问题】

    简介:Application Insights是微软发布的一个在线服务,可以监测自己的网站应用,进行性能管理以及使用分析. Application Insights功能一开始是出现在Visualstu ...

  6. [整理]Visual Studio 的Application Insights

    简单介绍 Application Insights(预览版) Visual Studio 的Application Insights插件简介 Application Insights for Visu ...

  7. (编译)使用 AppCenter 持续输出导出到 Application Insights

    原文地址:https://blog.xamarin.com/appcenter-continuous-export-application-insights/ 五星手机应用有一个特殊的特点:他们不会放 ...

  8. Azure Application Insights REST API使用教程

    本文是Azure Application Insights REST API的简单介绍,并会包含一个通过Python消费API的示例/小工具. 新加入的team中的一项工作是制作日常的运维报表,制作方 ...

  9. Azure Monitor(一)Application Insights

    一,引言 Azure Monitor 是 Azure 中的一项完整堆栈监视服务,是一种收集和分析遥测数据的服务.它提供了一组完整的功能来监视 Azure 资源以及其他云中和本地的资源.Azure Mo ...

  10. 【应用程序见解 Application Insights】在Application Insights中通过自定义查询结果定义指标并显示在Dashboard中

    问题情形 通过Application Insights收集到指标数据后,如Request,Trace,Exception.但是默认的Insights图表不能满足业务的需求,需要自定义相应的类SQL语句 ...

随机推荐

  1. [转帖]Oracle 通过 Exadata 云基础设施 X9M 提供卓越的数据库性能和规模

    https://www.modb.pro/db/397202 32个节点的RAC 服务器 每个服务器 两个 64核心的AMD CPU 四个线程干管理 252个线程进行数据库处理 252*32=8064 ...

  2. 通杀无限 debugger,目前只有 1% 的人知道!

    前言 相信很多小伙伴在进行 web 逆向的时候,都遇到过无限 debugger.最简单的方法,在 debugger 位置,点击行号,右键 Never pause here,永远不在此处断下即可.但是这 ...

  3. Python获取内存、CPU利用率,CPU温度

    最近一个项目的需求,在软件上加入硬件实时信息,大概搜索一下,没太好的结果,所以决定自己写一篇 我的代码不难发现,都使用了psutil包,为什么呢,别的包我没太关注,纯粹是这台机的环境上有这个包 如果大 ...

  4. 使用boot.iso镜像安装Oracle Linux 8

    本文记录使用boot.iso镜像安装Oracle Linux 8. 镜像下载 Oracle Linux 8 boot镜像可以从这里下载. 安装 Oracle Linux 8 boot镜像安装系统跟使用 ...

  5. SqlSugar更新数据

    1.根据实体对象更新 所谓按实体对象更新就是:db.Updateable(参数对象) 有参数的重载 db.Updateable(实体或者集合).ExecuteCommand() //右标题1 下面的所 ...

  6. C/C++ 实现枚举网上邻居信息

    在Windows系统中,通过网络邻居可以方便地查看本地网络中的共享资源和计算机.通过使用Windows API中的一些网络相关函数,我们可以实现枚举网络邻居信息的功能,获取连接到本地网络的其他计算机的 ...

  7. PostFix+Dovecot 部署邮件系统

    Postfix 是一种电子邮件服务器是一个开放源代码的软件. Postfix 是MTA邮件传输代理软件.是sendmail提供替代品的一个尝试,在Internet世界中,大部分的电子邮件都是通过sen ...

  8. 在K8S中,Pod亲和性概念是什么?

    在Kubernetes(简称K8S)中,Pod亲和性和反亲和性(Affinity and Anti-Affinity)是集群调度策略的重要组成部分,它们用于控制Pod如何与节点或其他Pod相对应地放置 ...

  9. ajax中的同步异步和跨域请求

    ajax中的同步异步和跨域请求 同步异步 demo.html <script> $.ajax({ type: "get", async: false, data: &q ...

  10. 关于大数乘法的数组类型问题(int 还是char)

    可以知道在处理高精度乘法的时候,我们是不考虑当场进位的,在所有位数都模拟完竖式乘法后才进行逐位进位,这就要求存储每个位的数组保证不会爆掉溢出 众所周知char类型最多只能存储到255,非常非常容易溢出 ...