1

在 Power BI(桌面)中,我们使用 Power BI 查询 (M) 从 Application Insights Analytics 获取数据。我们将 Power BI 报告发布到 Power BI Online,并配置了每日刷新。它工作正常,直到它在 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&amp;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&amp;x-ms-app=AAPBI

有谁知道如何解决这个问题?

4

2 回答 2

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

我只给出了几个例子,你必须确保它们符合你的仪表板的意图。

于 2017-01-26T16:16:56.813 回答
2

James 建议的建议是限制结果大小,但如果您仍需要返回更大的数据集,您可以直接使用 AI API 而不是 ARM。

1)您需要创建一个 API 密钥,请参阅https://dev.applicationinsights.io/documentation/Authorization/API-key-and-App-ID

2) 接下来,您需要通过将 ARM URL 替换为 AI API 来更新从 Analytics 导出的 Power BI M 脚本:

替换 ARM 调用:

.....
Source = Json.Document(Web.Contents(" https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/<RESOURCE GROUP>/providers/microsoft.insights/components/<APP NAME>/api/query?api-version=2014-12-01-preview", [Query=[#"csl"="requests",#"x-ms-app "="AAPBI"],Timeout=#duration(0,0,4,0)])),
......

通过 AI API 调用:

....
Source = Json.Document(Web.Contents(" https://api.applicationinsights.io/beta/apps/<APPLICATION_ID>/query?api-version=2014-12-01-preview", [Query=[#"csl"="requests",#"x-ms-app" ="AAPBI"],Timeout=#duration(0,0,4,0)])),
.....

3) 最后,将凭证更新为基本凭证,并使用您的 API 密钥

在此处输入图像描述

于 2017-04-08T18:34:56.847 回答