How to get multiple dimensions with Analytics API call?

Not applicable

Hi,

I have created a report with multiple dimensions, which are vin, username, pathsuffix , request timestamp and responseCode . Has only one metric Total_response_time.

I could see the report details when i drill down on each dimension. When i export to CSV file , i don't get all dimensions instead i get only first drilled down dimension. I realized to get all dimensions we can use Analytics API call.

But even with API call , i still get only one dimension at a time.

sample API call with filters is giving me only vin numbers.

https://api.enterprise.apigee.com/v1/organizations/nonprod/environments/dev/stats/vin?select=sum(mes... 00:00~05/30/2017 00:00&timeUnit=day&filter=(username in 'ABCD' and proxy_pathsuffix in '/v1/vin' and response_status_code eq 200)

Is it possible to get all dimensions by username in one call?

This should return

vin, pathsuffix, requesttimestap , responsecode

Solved Solved
0 11 1,513
1 ACCEPTED SOLUTION

Hi @Nalini - With the API, you can include multiple dimensions separated by commas. It doesn't order the subdimensions like you have in your sample JSON, but it does group by specific dimension combos.

For example, take this API call that gets message counts grouped by proxy and verb:

https://api.enterprise.apigee.com/v1/organizations/apigeedocs/environments/test/stats/apiproxy,request_verb?select=sum(message_count)&timeRange=05%2F15%2F2017%2000%3A00~05%2F20%2F2017%2023%3A59"

The response will come out like this:

{
      "dimensions": [
        {
          "metrics": [
            {
              "name": "sum(message_count)",
              "values": [
                "34522.0"
              ]
            }
          ],
          "name": "testCache,POST"
        },
        {
          "metrics": [
            {
              "name": "sum(message_count)",
              "values": [
                "17259.0"
              ]
            }
          ],
          "name": "helloworld-sampleproxy,GET"
        }

This example shows traffic for 1) testCache proxy and POST, 2) helloworld-sampleproxy and GET.

So your metric counts would be grouped VERY granularly, like this:

{
      "dimensions": [
        {
          "metrics": [
            {
              "name": "sum(message_count)",
              "values": [
                "34522.0"
              ]
            }
          ],
          "name": "/v1/specs,vin1,user1,200,date"
        },
        {
          "metrics": [
            {
              "name": "sum(message_count)",
              "values": [
                "17259.0"
              ]
            }
          ],
          "name": "/v1/specs,vin1,user2,200,date"
        }

...and so on.

Not sure if this is helpful, but it's how multiple dimensions in a single API call are grouped.

View solution in original post

11 REPLIES 11

Not applicable

You can request multiple metrics by separating them with commas. Here's a snippet of the documentation of what you can do. You can find more about it here.

sum(ax_cache_executed)
avg|min|max(ax_cache_l1_count)
sum(cache_hit)
sum(is_error)
sum(message_count)
sum(policy_error)
avg|min|max(request_processing_latency)
sum|avg|min|max(request_size)
avg|min|max(response_processing_latency)
sum|avg|min|max(response_size)
sum(target_error)
sum|avg|min|max(target_response_time)
sum|avg|min|max(total_response_time)
tps

@Diego Zuluaga

What you suggested is to get multiple metrics for a single dimension. I am looking to get multiple dimensions in a timerange with sinlge metric and filtered by username.

Got it. Then it's not possible as @Maruti Chand's response.

Not applicable

Hi @Nalini You should be making multiple calls. (one per dimension)

Refer this

https://community.apigee.com/questions/41431/access-custom-reports-data-via-analytics-api.html?child...

Write a script to do it for you.


Thanks @Maruti Chand and @Diego Zuluaga for your recommendations. Probably that's the only solution. I think there are some limitations and feel Apigee is not very flexible with Reporting. I am wondering even with API call it allows only one dimension. I have statistics collected on 5 dimensions and now its pain to make 5 calls per each user.

Thanks for your inputs.

Not applicable

@Nalini,

I think there is some confusion and apologies for not being very clear in my previous answer.
Let me explain it clearly and see if your impression changes.

Let's take the dimensions from my example

"dimensions":["apiproxy","request_verb","proxy_pathsuffix"],

apiproxy is the high-level dimension and it will have many request_verbs and proxy_pathsuffixes (subset dimensions) .

For example:

CustomerAPIproxy has endpoints which support GET and POST and has resources with path suffix /v1/customer and /v2/customer.

Now if you want to know the request_verb (GET+POST) stats for CustomerAPIproxy you can run

curl -v "https://api.enterprise.apigee.com/v1/organizations/{org}/environments/{environment}/stats/request_verb?filter=(apiproxy+eq+%27CustomerAPIproxy%27)&select=avg(total_response_time),avg(target_response_time),avg(request_processing_latency),avg(response_processing_latency),sum(message_count),sum(is_error)&sort=ASC&sortby=avg(total_response_time),avg(target_response_time),avg(request_processing_latency),avg(response_processing_latency),sum(message_count),sum(is_error)&timeRange=05%2F12%2F2017+21:37:00~05%2F12%2F2017+22:37:00&timeUnit=minute

If you want the stats for the proxy_pathsuffix for all the POST calls made to CustomerAPIproxy, you can use this filter

filter=(apiproxy+eq+%27CustomerAPIproxy%27)+and+(request_verb+eq+%27POST%27)

In your case, you can add more filters and get what you want with one API.

Let me know if that helps.
If it is not clear, pls share your use-case so that someone here or I can help you further.

@Maruti Chand Really appreciate your help, Thank you.

Still looking for an answer.

From your example set of dimensions it is understandable that both metrics and filter can be applied on a single dimension. And its not possible to get other dimensions in the same call. I think that is how the design is.

Let me explain my use case in detail.

Client submits a request with VIN number. So for report purpose i would collect stats on custom dimensions VIN and Username and other common dimensions like proxy_pathsuffix, request time and response code.

Order of dimensions as below:

"dimensions":["proxy_pathsuffix","username","vin","Response status code", "date time"],<br>

As per your explanation , in this use case proxy_pathsuffix is a high-level dimension and it will have many usernames, each username will have many vins , each Vin will have a response code so on and so forth.

Basically i view proxy_pathsuffix as a collection, because all dimensions can only be drilled down from that dimension. So, I want to get all dimensions within the collection.

I have already tried making call by pathsuffix stats and filtered by apiproxyname , username and response status code 200.

Below is the response. This is fine.

{
	"environments": [{
		"dimensions": [{
			"metrics": [{
				"name": "avg(total_response_time)",
				"values": [{
					"timestamp": 1496435940000,
					"value": "463.0"
				},
				{
					"timestamp": 1496433840000,
					"value": "593.0"
				}]
			}],
			"name": "/v1/specs"
		},
		{
			"metrics": [{
				"name": "avg(total_response_time)",
				"values": [{
					"timestamp": 1496435940000,
					"value": "0.0"
				},
				{
					"timestamp": 1496419260000,
					"value": "0.0"
				}]
			}],
			"name": "/v1/fin1"
		}],
		"name": "exp-dev"
	}],
	"metaData": {
		"errors": [],
		"notices": ["Spark engine used",
		"query served by:cf960e72-8ee8-45c0-a094-e5f9904b9ee5"]
	}
}

But i am looking for more data in json. I would like to have sub-dimension vin also listed within each dimension. Something like this

{
	"environments": [{
		"dimensions": [{
			"metrics": [{
				"name": "avg(total_response_time)",
				"values": [{
					"timestamp": 1496435940000,
					"value": "463.0"
				},
				{
					"timestamp": 1496433840000,
					"value": "593.0"
				}]
			}],
                 "subdimensions": {
                     "vin": {
                      "value": [
                        "vin1",
                        "vin2",
                        "vin3"
                      ]
                    }
                },
			"name": "/v1/specs"
		},
		{
			"metrics": [{
				"name": "avg(total_response_time)",
				"values": [{
					"timestamp": 1496435940000,
					"value": "0.0"
				},
				{
					"timestamp": 1496419260000,
					"value": "0.0"
				}]
			}],
                 "subdimensions": {
                     "vin": {
                      "value": [
                        "vin1",
                        "vin4",
                        "vin3",
                        "vin1"
                      ]
                    }
                },
"name": "/v1/fin1" }],
"name": "dev" }], "metaData": { "errors": [], "notices": ["Spark engine used", "query served by:cf960e72-8ee8-45c0-a094-e5f9904b9ee5"] } }

                   

I don't know if it's possible or not. But if there is any other approach please suggest.

Thanks.

Hi @Nalini - With the API, you can include multiple dimensions separated by commas. It doesn't order the subdimensions like you have in your sample JSON, but it does group by specific dimension combos.

For example, take this API call that gets message counts grouped by proxy and verb:

https://api.enterprise.apigee.com/v1/organizations/apigeedocs/environments/test/stats/apiproxy,request_verb?select=sum(message_count)&timeRange=05%2F15%2F2017%2000%3A00~05%2F20%2F2017%2023%3A59"

The response will come out like this:

{
      "dimensions": [
        {
          "metrics": [
            {
              "name": "sum(message_count)",
              "values": [
                "34522.0"
              ]
            }
          ],
          "name": "testCache,POST"
        },
        {
          "metrics": [
            {
              "name": "sum(message_count)",
              "values": [
                "17259.0"
              ]
            }
          ],
          "name": "helloworld-sampleproxy,GET"
        }

This example shows traffic for 1) testCache proxy and POST, 2) helloworld-sampleproxy and GET.

So your metric counts would be grouped VERY granularly, like this:

{
      "dimensions": [
        {
          "metrics": [
            {
              "name": "sum(message_count)",
              "values": [
                "34522.0"
              ]
            }
          ],
          "name": "/v1/specs,vin1,user1,200,date"
        },
        {
          "metrics": [
            {
              "name": "sum(message_count)",
              "values": [
                "17259.0"
              ]
            }
          ],
          "name": "/v1/specs,vin1,user2,200,date"
        }

...and so on.

Not sure if this is helpful, but it's how multiple dimensions in a single API call are grouped.

@Floyd Jones

Thank you very much. This is really helpful and what actually I am looking for. I am fine if it gives as grouped. I will be implementing this in my use case.

I referred documentation several times but no where it is mentioned about how to access multiple dimensions. I hope documentation gets updated.

@Floyd Jones Good to know that we can retrieve the data for multiple dimensions in a single API . Can we document this as this was requested by many people and update here with the link?

@Nalini and @Maruti Chand, I've updated the API doc to show multiple dimensions. I'm also trying to finish up a topic that describes this in more detail and compares the multi-dimension experience in the UI vs. the API.

I'll be sure to include your findings about export to CSV--that only the the first drilled-down dimension gets exported.