Mat*_*und 4 report azure azure-application-insights
我们正在使用Application Insight,并添加了几个Web测试来监控我们的网站.网络测试全部每5分钟从三个位置运行,并且所有三个位置都需要在5分钟内失败才能使警报响起.
Application Insights中是否有一些报告可用于向我们的客户报告上个月的可用性?我们需要至少有一个小数的可用性百分比.
更新:基于@ZakiMa的答案,我最终得到以下查询:
let lastmonthstart = startofmonth(now(), -1);
let lastmonthend = endofmonth(lastmonthstart);
availabilityResults
| where timestamp between(lastmonthstart .. lastmonthend)
| summarize failurecount=countif(success == 0), successcount=countif(success == 1) by name, bin(timestamp, 5m)
| project failure = iff(failurecount > 0 and successcount == 0, 1, 0), name, bin(timestamp, 5m)
| summarize totalFailures = sum(failure), totalTests = count(failure) by name
| project ["Name"] = name, ["SLA"] = todouble(totalTests - totalFailures) / todouble(totalTests) * 100
| order by ["SLA"]
Run Code Online (Sandbox Code Playgroud)
您可以使用Application Insights Analytics计算SLA.单击概述页面上的"Analytics"菜单项,然后使用以下查询:
availabilityResults
| where timestamp > ago(30d)
| summarize _successCount=todouble(countif(success == 1)),
_errorCount=todouble(countif(success == 0)),
_totalCount=todouble(count()) by name
| project
["Name"] = name,
["SLA"] = _successCount / _totalCount * 100
| order by ["SLA"]
Run Code Online (Sandbox Code Playgroud)
你应该得到这样的东西:
然后你可以将它固定到仪表板上(右上角有一个图钉图标):
这只是一个示例 - 在这里您可以找到完整的分析查询语言参考 - 它非常强大:https://docs.microsoft.com/en-us/azure/application-insights/app-insights-analytics-reference.您可以根据自己的SLA定义进行调整.
编辑:这是一个更接近您的问题的查询示例
availabilityResults
| where timestamp > ago(30d)
// check whether location failed within 5m bin
| summarize _failure=iff(countif(success == 0)>0, 1, 0) by name, location, bin(timestamp, 5m)
// check whether all locations failed within 5m bin
| summarize _failureAll=iff(sum(_failure)>=3, 1, 0) by name, bin(timestamp, 5m)
// count all failed 5 minute bins and total number of bins
| summarize _failuresCount=sum(_failureAll), _totalCount=count() by name
| project ["Name"] = name,
["SLA"] = todouble(_totalCount - _failuresCount) / todouble(_totalCount) * 100
| order by ["SLA"]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1816 次 |
最近记录: |