Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我如何让Application Insights Rest Api返回所有数据,即使它没有';不存在?_Rest_Azure_Azure Application Insights - Fatal编程技术网

我如何让Application Insights Rest Api返回所有数据,即使它没有';不存在?

我如何让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

因此,我尝试使用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.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类型(日期时间)

如何将度量转换为查询?有什么地方可以让我了解app insight querys吗?@CallumBrankin我使用application insight开始大部分查询。在右上角所有图表的顶部是一个奇怪的图标,看起来像一页框。如果单击该按钮,您将进入用于创建该图表的查询,您所要做的就是复制和粘贴(删除查询底部的图表语句)。如果在过去24小时内没有记录任何数据,则不会返回任何内容并导致未定义的错误。即使在过去24小时内未记录任何数据,是否可以使其始终返回数据?