简体   繁体   English

如何从Azure Application Insights API中选择多个CustomDimensions?

[英]How to select multiple CustomDimensions from Azure Application Insights API?

I'm trying to select events that have three CustomDimensions fields set: MessageType, MessageName and MessageID. 我试图选择具有三个CustomDimensions字段设置的事件:MessageType,MessageName和MessageID。

The events also contain the content of the message, which can be quite large, so I don't want to get that in the response. 事件还包含消息的内容,该内容可能很大,因此我不想在响应中得到它。

So I'm using the $select operator to select a subset of fields available in the events. 因此,我使用$ select运算符来选择事件中可用字段的子集。

The $select query is as follows: id, timestamp, customDimensions/MessageID, customDimensions/MessageName, customDimensions/MessageType $ select查询如下: id, timestamp, customDimensions/MessageID, customDimensions/MessageName, customDimensions/MessageType

No matter what I do I always get the last CustomDimension and not all three. 无论我做什么,我总是得到最后的 CustomDimension,而不是全部三个。 Example response: 响应示例:

 "id": "bc33c887-e100-11e8-9830-effc6d3968d7",
  "timestamp": "2018-11-05T13:42:58.240Z",
  "customDimensions": {
    "MessageType": "RESPONSE"
  }

Is there a special syntax for selecting more CustomDimension fields from the events? 从事件中选择更多CustomDimension字段是否有特殊的语法?

You can refer to this issue , and I have already mailed to MS for this issue, but no feedback now. 您可以参考此问题 ,并且我已经就此问题邮寄给MS,但现在没有反馈。

As a workaround, you can use this solution(You can ajust the ago(5h) as per your need),official document here : 作为解决方法,您可以使用此解决方案(您可以根据需要调整ago(5h) ), 这里是官方文件:

https://api.applicationinsights.io/v1/apps/Your_application_id/query?query=events
| where timestamp >ago(5h)
|  project id, timestamp, customDimensions.MessageID, customDimensions.MessageName,customDimensions.MessageType

Then you can test it in postman like this: 然后,您可以像这样在邮递员中对其进行测试: 在此处输入图片说明

How to get the application id and api key: 如何获取应用程序ID和API密钥:

Nav to azure portal -> your application insights -> API Access blade, then you can see the Application id . 导航至azure门户->您的应用程序见解-> API Access刀片,然后您可以看到Application id

Then click the Create API key button, in the create api key page, select the Read telemetry checkbox, then click Generate key button. 然后单击“ Create API key按钮,在“创建api密钥”页面中,选中“ Read telemetry复选框,然后单击“生成密钥”按钮。 Please remember the api key, if it's lost, you need to generate a new one . 请记住api密钥,如果丢失了,则需要生成一个新密钥

在此处输入图片说明

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM