Application Insights API $select not returning all

2019-08-03 05:37发布

问题:

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.