在Power BI(桌面)中,我们使用Power BI查询(M)从Application Insights Analytics获取数据。我们将Power BI报告发布到Power BI在线,并配置了每日刷新功能。它工作正常,直到它在25-1-2017(UTC)停止工作。
我们得到的错误是:
DataSource.Error: Web.Contents failed to get contents from '.....' (502): Bad Gateway
这是完整的错误:
DataSource.Error: Web.Contents failed to get contents from 'https://management.azure.com/subscriptions/<subscriptionId>/resourcegroups/fps.fsa/providers/microsoft.insights/components/4PS%20Field%20Service%20iOS%20-%20iOS/api/query?api-version=2014-12-01-preview&csl=customEvents%0A%7C%20where%20timestamp%20%3E%20ago%2830d%29%0A%7C%20order%20by%20timestamp%20desc%0A%7C%20extend%20dimensionUserId%20%3D%20tostring%28customDimensions.%5B%27userId%27%5D%29%0A%7C%20extend%20dimensionHost%20%3D%20tostring%28customDimensions.%5B%27url%27%5D%29%0A%7C%20extend%20measurementQuantity%20%3D%20iff%28%20isnotempty%28customMeasurements.%5B%27value%27%5D%29%2C%20todouble%28customMeasurements.%5B%27value%27%5D%29%2C%200.0%29%0A%7C%20extend%20measurementKey%20%3D%20tostring%28customDimensions.%5B%27key%27%5D%29%0A%7C%20extend%20platform%20%3D%20%27iOS%27%0A&x-ms-app=AAPBI' (502): Bad Gateway
Details:
DataSourceKind=Web
DataSourcePath=https://management.azure.com/subscriptions/<subscriptionId>/resourcegroups/fps.fsa/providers/microsoft.insights/components/4PS%20Field%20Service%20iOS%20-%20iOS/api/query
Url=https://management.azure.com/subscriptions/<subscriptionId>/resourcegroups/fps.fsa/providers/microsoft.insights/components/4PS%20Field%20Service%20iOS%20-%20iOS/api/query?api-version=2014-12-01-preview&csl=customEvents%0A%7C%20where%20timestamp%20%3E%20ago%2830d%29%0A%7C%20order%20by%20timestamp%20desc%0A%7C%20extend%20dimensionUserId%20%3D%20tostring%28customDimensions.%5B%27userId%27%5D%29%0A%7C%20extend%20dimensionHost%20%3D%20tostring%28customDimensions.%5B%27url%27%5D%29%0A%7C%20extend%20measurementQuantity%20%3D%20iff%28%20isnotempty%28customMeasurements.%5B%27value%27%5D%29%2C%20todouble%28customMeasurements.%5B%27value%27%5D%29%2C%200.0%29%0A%7C%20extend%20measurementKey%20%3D%20tostring%28customDimensions.%5B%27key%27%5D%29%0A%7C%20extend%20platform%20%3D%20%27iOS%27%0A&x-ms-app=AAPBI
有谁知道如何解决这个问题?
答案 0 :(得分:4)
502 Bad Gateway Message通常是由于AA Query返回的数据过多。网关限制为8MB数据,周期。
您创建了一个2016年12月起作用的信息中心,并在本月初向您提供了所有请求。现在是2017年1月,它失败了。您可以使用PowerBI仪表板使用如下所示的查询从原始结果中计算一些指标。
requests | where timestamp > datetime(2016-12-01)
确定您真正关心的天数。如果您的目的是获得所有请求以及本月第一天的时间,您可以通过限制本月的时间范围来减少大量额外数据,并且只预测您需要的列
requests | where timestamp > startofmonth(now()) | project name, duration
假设您正在计算平均值和百分位数等内容,您也可以让Analytics为您执行此操作,而PowerBI只显示结果。
requests | where timestamp > startofmonth(now()) | summarize count(), avg(duration), min(duration), max(duration), stdev(duration), percentiles(duration, 50, 75, 90, 95, 99) by name
您可能需要一个有意义的图表,因此您可以按时间段拆分聚合。这将为您提供大量数据作为回报,但如果您查询原始数据点,则会比您获得的数据要少得多。
requests | where timestamp > startofmonth(now()) | summarize count(), avg(duration), min(duration), max(duration), stdev(duration), percentiles(duration, 50, 75, 90, 95, 99) by bin(timestamp, 1d), name
requests | where timestamp > startofmonth(now()) | summarize count(), avg(duration), min(duration), max(duration), stdev(duration), percentiles(duration, 50, 75, 90, 95, 99) by bin(timestamp, 1h), name
我只举了几个例子,你必须确保它们符合仪表板的意图。
答案 1 :(得分:2)
James建议的建议是限制结果大小,但如果仍然需要返回更大的数据集,则可以直接使用AI API而不是ARM。
1)您需要创建API密钥,请参阅https://dev.applicationinsights.io/documentation/Authorization/API-key-and-App-ID
2)接下来,您需要通过使用AI API替换ARM URL来更新从Google Analytics导出的Power BI M脚本:
替换ARM调用:
.....
来源= Json.Document(Web.Contents(&#34;https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/<RESOURCE GROUP>/providers/microsoft.insights/components/<APP NAME>/api/query
API版本= 2014年12月1日预览&#34 ;, [查询= [#&#34; CSL&#34; =&#34;请求&#34;,#&#34; X-MS-应用&#34; =&#34; AAPBI&#34],超时=#持续时间(0,0,4,0)])),
.....
使用AI API调用:
....
来源= Json.Document(Web.Contents(&#34;https://api.applicationinsights.io/beta/apps/<APPLICATION_ID>/query
API版本= 2014年12月1日预览&#34 ;, [查询= [#&#34; CSL&#34; =&#34;请求&#34;,#&#34; X-MS-应用&#34; =&#34; AAPBI&#34],超时=#持续时间(0,0,4,0)])),
.....
3)最后,将凭据更新为基本,并使用您的API密钥