到目前为止,我成功使用 Application Insights REST API 来获取带有 X-Api-Key 标头的指标。
然而,通过我们的新仪表板,抓取多个指标,我们严重达到了 1500 个请求/API 密钥的限制。
有些人建议尝试使用多个 api 密钥,但我想阻止这种方法。
根据文档,使用 AAD 进行身份验证将取消每日上限(https://dev.applicationinsights.io/documentation/Authorization/Rate-limits https://dev.applicationinsights.io/documentation/Authorization/Rate-limits)
但我无法使用AAD进行身份验证(在nodejs中,但我怀疑它在任何语言中都是相同的)
I used adal-node
使用一个简单的应用程序,我成功获得了一个令牌,但是我无法将其转发到Request
var context = new AuthenticationContext(authorityUrl);
context.acquireTokenWithClientCredentials(resource, clientId, clientSecret, function(err, tokenResponse) {
if (err) {
console.log('well that didn\'t work: ' + err.stack);
} else {
console.log(tokenResponse);
request({'url' : 'https://api.applicationinsights.io/beta/apps/xxxxxxxxx/metrics/customMetrics%2Fmetrics?timespan=PT2H&interval=PT20M&aggregation=min',
headers: {
'Authorization': 'Bearer ' + tokenResponse.accessToken
}
}, function (error,response,body){
console.log(body);
});
}
});
我收到以下错误消息The provided authentication is not valid for this resource
The given API Key is not valid for the requested resource
我怀疑我错过了什么:)