【Azure Developer】使用cmd脚本循环执行curl请求

简介: 在Application Insights 及 Log A 达到每日摄入数据量上限后,及时调整到更大的限制值,也不能及时恢复数据收集。只能等待Log A 的重置时间。

问题描述

在测试Application Insights的每日上限(Daily Cap)功能,想通过最简单的 curl 脚本来循环发送请求,验证日志摄入量大道设置的300MB (0.03GB)后,是否可以通过调大Daily Cap限制值马上恢复数据的摄入!

 

问题解答

一个简单的 CMD 脚本示例,它会循环执行 curl 命令:

@echo off
:loop
curl http://example.com
timeout /t 60
goto loop

这个脚本会不断地执行 curl http://example.com 命令,并在每次执行后等待 60 秒。如果需要修改 URL 或等待时间,只需替换相应的部分即可。

 

根据从M365 Copilot中获取的答案,直接把 http内容 替换为 向Application Insights发送 sample test data 的 Request 。 修改后的 CMD 脚本为:

@echo off

:loop

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\":\"SampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultSampleWebtestResultlt\",\"properties\":{\"SampleProperty\":\"SampleValue\"}},\"baseType\":\"AvailabilityData\"},\"ver\":1,\"name\":\"Microsoft.ApplicationInsights.Metric\",\"time\":\"2024-12-11T05:18:22.0000000Z\",\"sampleRate\":100,\"iKey\":\"<xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>\",\"flags\":0} https://chinanorth3-0.in.applicationinsights.azure.cn/v2/track

timeout /t 0

goto loop

执行效果为:

 

通过持续不断的循环请求,最后验证了在Application Insights 及 Log A 达到每日摄入数据量上限后,及时调整到更大的限制值,也不能及时恢复数据收集。只能等待Log A 的重置时间。

 

参考资料

用于发送可用性测试结果的 Curl 命令 :  https://learn.microsoft.com/zh-cn/troubleshoot/azure/azure-monitor/app-insights/telemetry/investigate-missing-telemetry#curl-command-send-availability-test-result



当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

相关文章
|
5月前
|
Ubuntu Linux 测试技术
【Azure Function App】Python Function调用Powershell脚本在Azure上执行失败的案例
【Azure Function App】Python Function调用Powershell脚本在Azure上执行失败的案例
|
关系型数据库 API C#
C#调用执行命令行窗口cmd,及需要交互执行的处理
C#执行外部程序用到的是Process进程类,打开一个进程,可以指定进程的启动信息StartInfo(启动的程序名、输入输出是否重定向、是否显示UI界面、一些必要参数等)...
3187 0
C#调用执行命令行窗口cmd,及需要交互执行的处理
|
Shell PHP Windows
php交互式命令行工具window操作系统安装readline扩展函数实现interactive mode enabled到Interactive Shell
php交互式命令行工具window操作系统安装readline扩展函数实现interactive mode enabled到Interactive Shell
118 0
shell 脚本中包含环境变量的设置命令需要用 source 命令执行才会生效
shell 脚本中包含环境变量的设置命令需要用 source 命令执行才会生效
|
Java Shell 程序员
Power Shell 脚本——基于curl自动批量获取FTP服务器上的日志文件
Power Shell 脚本——基于curl自动批量获取FTP服务器上的日志文件
309 0
Power Shell 脚本——基于curl自动批量获取FTP服务器上的日志文件
|
Shell 开发工具 git
easyswoole 更新代码shell
easyswoole 更新代码shell
86 0
|
Shell Linux Go
在 Go 语言中使用 exec 包执行 Shell 命令(上)
exec 是 os 包中的一个子包,它可用于使用 Go 运行外部命令。Go exec 命令教程展示了如何在 Golang 中执行 shell 命令和程序。
|
Shell Go
在 Go 语言中使用 exec 包执行 Shell 命令(下)
exec 是 os 包中的一个子包,它可用于使用 Go 运行外部命令。Go exec 命令教程展示了如何在 Golang 中执行 shell 命令和程序。