【发布时间】:2017-12-14 09:40:47
【问题描述】:
我在我创建的 Azure WebApp 上启用了应用程序洞察。我的 WebApp 正在调用按配额运行的第三方 API。我每个月只能打 10 万个电话。
我需要跟踪这些 API 调用,以便在调用次数达到 50% 时创建警报,然后再创建警报 75%。
每次进行调用并且 AppInsights 仪表板中的事件确实增加时,我都在使用 TrackEvent。但是当拨打一定数量的电话时,我似乎无法创建警报。我无法从“事件”下拉列表中看到它。
此外,我需要的另一个要求是在每分钟调用超过 10 次时创建警报。
TrackEvent 是满足这些要求的正确方法吗?
我做了这样的事情......
var telemetryEventClient = new Microsoft.ApplicationInsights.TelemetryClient(new Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration() { InstrumentationKey = "Instrumentation Key" });
telemetryEventClient.Context.Operation.Name = "MyAPIProvider";
var properties = new Dictionary<string, string>
{
{ "Source", "WebAppToAPI" }
};
var metrics = new Dictionary<string, double>
{
{ "CallingAPIMetric", 1 }
};
telemetryEventClient.TrackEvent("CallingAPI", properties, metrics);
但是当我查看设置警报并将阈值设置为 50000(为了测试,我只设置了 5)时,我从未达到过该值,因为事件计数始终为 1。我是否以正确的方式接近这个值?
【问题讨论】:
标签: azure alert monitoring azure-application-insights