【Application Insights】使用CURL命令向Application Insgihts发送测试数据
问题描述
在使用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小时的数据:
参考资料
用于发送可用性测试结果的 Curl 命令 : https://learn.microsoft.com/zh-cn/troubleshoot/azure/azure-monitor/app-insights/investigate-missing-telemetry#curl-command-send-availability-test-result
【Application Insights】使用CURL命令向Application Insgihts发送测试数据的更多相关文章
- 【应用程序见解 Application Insights】使用Azure Monitor Application Insights Agent获取Azure VM中监控数据及IIS请求指标等信息
问题情形 为了使用Application Insights也可以监控Azure VM中的相关性能数据,如CPU, Memory,IIS Reuqest等信息,可以在VM中开始一个一个扩展插件: Azu ...
- 【应用程序见解 Application Insights】Application Insights 使用 Application Maps 构建请求链路视图
Applicaotn Insigths 使用 Application Maps 构建请求链路视图 构建系统时,请求的逻辑操作大多数情况下都需要在不同的服务,或接口中完成整个请求链路.一个请求可以经历 ...
- 【Azure 应用程序见解】Application Insights Java Agent 3.1.0的使用实验,通过修改单个URL的采样率来减少请求及依赖项的数据采集
问题描述 近日好消息,如果是一个Java Spring Cloud的项目,想使用Azure Applicaiton Insights来收集日志及一些应用程序见解.但是有不愿意集成SDK来修改代码或者配 ...
- 使用Application Insights 做分析
Application Insights on Windows Desktop apps, services and worker roles : https://azure.microsoft.co ...
- 关于Application Insights遥测功能使用【遇到问题】
简介:Application Insights是微软发布的一个在线服务,可以监测自己的网站应用,进行性能管理以及使用分析. Application Insights功能一开始是出现在Visualstu ...
- [整理]Visual Studio 的Application Insights
简单介绍 Application Insights(预览版) Visual Studio 的Application Insights插件简介 Application Insights for Visu ...
- (编译)使用 AppCenter 持续输出导出到 Application Insights
原文地址:https://blog.xamarin.com/appcenter-continuous-export-application-insights/ 五星手机应用有一个特殊的特点:他们不会放 ...
- Azure Application Insights REST API使用教程
本文是Azure Application Insights REST API的简单介绍,并会包含一个通过Python消费API的示例/小工具. 新加入的team中的一项工作是制作日常的运维报表,制作方 ...
- Azure Monitor(一)Application Insights
一,引言 Azure Monitor 是 Azure 中的一项完整堆栈监视服务,是一种收集和分析遥测数据的服务.它提供了一组完整的功能来监视 Azure 资源以及其他云中和本地的资源.Azure Mo ...
- 【应用程序见解 Application Insights】在Application Insights中通过自定义查询结果定义指标并显示在Dashboard中
问题情形 通过Application Insights收集到指标数据后,如Request,Trace,Exception.但是默认的Insights图表不能满足业务的需求,需要自定义相应的类SQL语句 ...
随机推荐
- C#开源免费的开发效率提升利器:DevToys开发人员的瑞士军刀!
前言 今天分享一款基于C#开源(MIT License开源协议).免费.离线.功能齐全的Windows开发者工具箱,号称开发人员的瑞士军刀,可以帮助开发者完成日常工作开发中常用功能:DevToys. ...
- vue中$children的理解
官网介绍 $children $children 获取当前实例的直接子组件 .需要注意 $children 并不保证顺序,也不是响应式的.[特别重要] 如果你发现自己正在尝试使用 $children ...
- vue面试题(一)正在重新整理
1.输入一个 URL到浏览器整个过程发生了什么?ok 1.浏览器查找当前 URL是否存有缓存,并检查这个缓存是否过期 2.DNS 解析 URL 对应的 IP 3.根据 IP 建立 TCP 连接(三次握 ...
- 在K8S中,Pod生命周期包含哪些?
在Kubernetes(简称K8s)中,Pod的生命周期经历了一系列状态变化.以下是Pod可能处于的一些主要状态: Pending: 当创建一个Pod时,它首先会进入Pending状态.这个状态下,K ...
- 基于.net Core+EF Core项目的搭建(一)
在我们要使用EF的项目中引用两个包Microsoft.EntityFrameworkCore.SqlServer和Microsoft.EntityFrameworkCore.Tools 我把要使用的E ...
- 从零开始配置 vim(15)——状态栏配置
vim 下侧有一个状态栏,会显示当前打开的文件等一系列内容,只是我们很少去关注它.而且原生的vim也支持对状态栏进行自定义.这篇文章主要介绍如何自定义状态栏 设置状态栏 我们可以采用 set stat ...
- MySQL8.0配置my.cnf
环境 centos7.9 mysql Ver 8.0.32 因为是源码安装的MySQL8.0.32,查了一下MySQL 8.0之后源码中不包含my.cnf文件和my-default.cnf文件了. ...
- Docker从认识到实践再到底层原理(六-2)|Docker容器操作实例
前言 那么这里博主先安利一些干货满满的专栏了! 首先是博主的高质量博客的汇总,这个专栏里面的博客,都是博主最最用心写的一部分,干货满满,希望对大家有帮助. 高质量博客汇总 然后就是博主最近最花时间的一 ...
- Spring Cloud Config核心功能和原理解析
配置管理的前世今生 随着技术的发展,配置项管理变得越来越简单,尽管如今它只限于管理业务属性或者配置初始化参数等等,但是当年它可肩负着 Spring IOC 的光荣使命,风光无限. 想当年刚入行的时候还 ...
- RHEL7安装11204 RAC的注意事项
最近在某客户的RHEL7 + 11204 RAC环境上测试遇到不少的坑,好在都赶在正式上线前及时发现并处理完毕. 其中两个问题比较典型所以特别记录下:问题都和主机重启后,O相关服务没有自启动导致,看来 ...