Count for apiproxy and request_url not matching up

Not applicable

I am making two calls. One at the proxy level

stats/apiproxy?select=sum(message_count)&timeRange=4%2F11%2F2015+00%3A00%7E4%2F17%2F2015+00%3A00&timeUnit=week

And one to drill down at the request_url

stats/request_path?select=count(request_path)&timeUnit=week&timeRange=4%2F11%2F2015+00%3A00%7E4%2F17%2F2015+00%3A00

I was expecting to parse the response from the second one and sum that up to the first one but that's not happening. Any ideas?

Solved Solved
0 13 339
1 ACCEPTED SOLUTION

Not applicable

I am seeing very conflicting results

This is dumped from my code

stats/request_path?select=count(message_count)&timeUnit=day&timeRange=4%2F14%2F2015+04%3A00%7E4%2F15%2F2015+04%3A00

TotalCount: 9213.0

stats/proxy?select=count(message_count)&timeUnit=day&timeRange=4%2F14%2F2015+04%3A00%7E4%2F15%2F2015+04%3A00

TotalCount: 33927.0

All I am doing is reading metrics.values.values I must be missing something simple 😞

View solution in original post

13 REPLIES 13

in your first API, you are counting the message count, basically the trafffic, while in the second request you are counting the unique request_path, thats the reason the count is not matching.

You should be counting the same metric in both the api calls,

btw, for drilldown you could use filter param

http://apigee.com/docs/analytics-services/reference/analytics-reference

Hey thanks for responding. So I am definitely missing something. Won't the total number of messages hitting the platform be broken down by the unique URL? We have a base proxy that is taking all the requests and I want to be able to report on count for the unique URIs. How would I achieve that?

so, lets say you want the total number of messages broken down by the api proxy - then you would do

stats/apiproxy?select=sum(message_count)

lets say you want the total number of messages broken down by the request path - then you would do

stats/request_path?select=sum(message_count)

Note that, the dimension by which you break down only changes, but the metric does not. does it help?

Right so if the first call returns 10K records between 2 proxies, the second call should also return 10K but instead of just 2 metrics node it will have many more metrics nodes, right? But the total for the two API calls should be the same, right?

yes, correct - lets say first call returns for 2 proxies [lets say 6k,4k = 10k],

second call, lets say, returns 4 unique urls [3k,2k,4k,1k=10k]

Not applicable

I am seeing very conflicting results

This is dumped from my code

stats/request_path?select=count(message_count)&timeUnit=day&timeRange=4%2F14%2F2015+04%3A00%7E4%2F15%2F2015+04%3A00

TotalCount: 9213.0

stats/proxy?select=count(message_count)&timeUnit=day&timeRange=4%2F14%2F2015+04%3A00%7E4%2F15%2F2015+04%3A00

TotalCount: 33927.0

All I am doing is reading metrics.values.values I must be missing something simple 😞

yeah looks like, i just checked in my org. I get same values.. can you share your code on how you are counting?

Truly appreciate your help! 


      JSONArray dimensions = apigeeHelper.parsejSONResponse(response);
      
      for (int loopCount = 0; loopCount < dimensions.length(); loopCount++) {
          JSONArray metrics = dimensions.getJSONObject(loopCount).getJSONArray("metrics");
          String apigeeEndPoint = dimensions.getJSONObject(loopCount).getString("name");
          System.out.println(metrics.getJSONObject(0).getJSONArray("values").length());
          String count = metrics.getJSONObject(0).getJSONArray("values").getJSONObject(0).get("value").toString();
          totalCount = totalCount + Double.parseDouble(count);
}




    public JSONArray parsejSONResponse(String inputString) throws JSONException {
        JSONObject obj = new JSONObject(inputString);
        JSONObject environments = (JSONObject) obj.getJSONArray("environments").get(0);
        return environments.getJSONArray("dimensions");
    }

ok, one problem could be this line,

metrics.getJSONObject(0).getJSONArray("values").getJSONObject(0).get("value").toString();

values is an array - probably could have multiple values

can you inspect your complete response to see if there are multiple values for any metric?

Not applicable

I am really stuck at this. Two calls with exact same parameters are coming back with 2 different results. Can I get on call with someone to see if this can be resolved at the earliest?

>>> Sending GET request to prod/stats/request_path?select=count(message_count)&timeUnit=day&timeRange=4%2F15%2F2015+00%3A00%7E4%2F16%2F2015+00%3A00

Fri Apr 17 08:22:03 EDT 2015 <<< TotalCount: 26325.0

>>> Sending GET request to prod/stats/proxy?select=count(message_count)&timeUnit=day&timeRange=4%2F15%2F2015+00%3A00%7E4%2F16%2F2015+00%3A00

Fri Apr 17 08:25:08 EDT 2015 <<< TotalCount: 207817.0

i would suggest you pls create a support ticket for this - https://pages.apigee.com/request-support-general.html

with your org details

I am going to close this thread as I realized it it returning more that 1000 records. I tried looking up the doc and could not find how do you send the paging request. I can close this open a new question.

Found the syntax in the forum. I am good with this thread