我如何让Application Insights Rest Api返回所有数据,即使它没有';不存在?
因此,我尝试使用get请求,使用演示凭据获取最后一天每小时的浏览器异常数:我如何让Application Insights Rest Api返回所有数据,即使它没有';不存在?,rest,azure,azure-application-insights,Rest,Azure,Azure Application Insights,因此,我尝试使用get请求,使用演示凭据获取最后一天每小时的浏览器异常数: https://api.applicationinsights.io/beta/apps/DEMO_APP/metrics/exceptions/browser?timespan=P1D&interval=PT1H 但它不会返回所有数据,它只返回已设置的数据,如图所示: { start: '2017-08-22T13:00:00.000Z', end: '2017-08-22T14:00:00.000
https://api.applicationinsights.io/beta/apps/DEMO_APP/metrics/exceptions/browser?timespan=P1D&interval=PT1H
但它不会返回所有数据,它只返回已设置的数据,如图所示:
{
start: '2017-08-22T13:00:00.000Z',
end: '2017-08-22T14:00:00.000Z',
'exceptions/browser': { sum: 1 }
}
{
start: '2017-08-23T04:00:00.000Z',
end: '2017-08-23T05:00:00.000Z',
'exceptions/browser': { sum: 1 }
}
如何使它返回每一位数据,即使总和为0?例如:
{
start: '2017-08-22T13:00:00.000Z',
end: '2017-08-22T14:00:00.000Z',
'exceptions/browser': { sum: 1 }
}
{
start: '2017-08-23T14:00:00.000Z',
end: '2017-08-23T15:00:00.000Z',
'exceptions/browser': { sum: 0 }
}
{
start: '2017-08-23T15:00:00.000Z',
end: '2017-08-23T16:00:00.000Z',
'exceptions/browser': { sum: 0 }
}
{
start: '2017-08-23T16:00:00.000Z',
end: '2017-08-23T17:00:00.000Z',
'exceptions/browser': { sum: 1 }
}
如果使用API的度量部分,请使用查询部分 查询仍将返回Json,但返回的是odata标准中的Json。这意味着需要涉及寻呼
查询调用将允许您返回所有列和行。这将需要使用查询API,并使用将查询形式化。
我正在运行以获取与您所需相同的数据的查询是:
exceptions
| where timestamp >= ago(24h)
| where client_Type=="Browser"
| make-series count() default=0 on timestamp in range(ago(24h), now(), 1h)
| mvexpand count_ to typeof(long), timestamp to typeof(datetime)
需要注意的几件事:
- 我使用
进行筛选,以匹配client\u Type==“Browser”
查询异常/Browser
- 为了“填空”,你必须使用
而不是make series
summary
- 查询的最终URL为:
https://api.applicationinsights.io/beta/apps/DEMO_APP/query?query=exceptions%7C%20where%20timestamp%20%3E%3D%20ago(24小时)%7C%20其中%20客户端类型%3D%3D%22浏览器%22%7C%20制作系列%20count()%20默认值%3D0%20on%20时间戳%20在%20范围内(以前(24小时)%2C%20now()%2C%201h)%7C%20mvexpand%20count\20到%20typeof(长)%2C%20时间戳%20到%20类型(日期时间)