Application Insights API $select not returning all results when values share part of path

社会主义新天地 提交于 2019-12-11 06:35:14

问题


I'm not sure if this is an OData issue or an Application Insights issue, but the App Insights API is not giving me all of the values I selected. It works normally most of the time, but when I ask for two values that share the beginning of their path, it only gives me the second value I asked for.

Here's an example of my issue:

data:

{
  "count": 1,
  "type": "customEvent",
  "customDimensions": {
    "success": "true",
    "version": "ver-1"
  },
  "other": {
    "key": "val-1"
  }
},
{
  "count": 2,
  "type": "customEvent",
  "customDimensions": {
    "success": "false",
    "version": "ver-2"
  },
  "other": {
    "key": "val-2"
  }
}

These all return the results that I'm expecting:

Query: $select=count,type

{
  "count": 1,
  "type": "customEvent"
},
{
  "count": 2,
  "type": "customEvent"
}

Query: select=customDimensions/success,other/key

{
  "customDimensions": {
    "success":"true"
  },
  "other": {
    "key":"ver-1"
  }
},
{
  "customDimensions": {
    "success":"false"
  },
  "other": {
    "key":"ver-2"
  }
}

However, if I try to get two values that start with the same path, it only shows me the second one.

Query: select=customDimensions/success,customDimensions/version

{
  "customDimensions": {
    "version":"ver-1"
  }
},
{
  "customDimensions": {
    "version":"ver-2"
  }
}

Is this an issue with either OData or Application Insights, or is there some other way I can format my query to give me the information I want? Thanks!


回答1:


Update: You can use the query api as following to fetch the data:

https://api.applicationinsights.io/v1/apps/Your_application_id/query?query=requests
| where timestamp >ago(5h)
|  project customDimensions.UsersNamed, customDimensions.TenantsCoded 

I test it in postman, see screenshot below:

Seems that your App Insights query is ok, I tested it using this .

I fetch the operation/name and operation/id(which starts with same path), original like this:

Then input some necessary condition, as screenshot below:

After click "Fetch" button, you can see the operation/name and operation/id are both returned.



来源:https://stackoverflow.com/questions/52300303/application-insights-api-select-not-returning-all-results-when-values-share-par

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!