Was this helpful?

 

Base Path: https://api.enterprise.apigee.com/v1/o/{org_name}

API Resource Path:

/environments/{env_name}/stats/{dimension_name}

Description: Use the GET method to retrieve metrics for a dimension

Verb: GET
Auth: Basic Auth
Media types:
application/json

Overview:

The /stats resource provides access to metrics collected by Apigee Edge.

Apigee Edge records and aggregates metrics for dimensions.

Apigee Edge defines 3 classes of dimensions:

  • Pre-computed, static dimensions used for operational dashboards
  • Dynamic dimensions, whose metrics are computed 'on-demand' when a report is built
  • Custom dimensions, which enable you to build reports based on message content

For each type of dimension, you construct a request by adding the desired dimension by name as a URI parameter following /stats.

For example:

/stats/apis

You can define queries against the collected metrics by specifying metrics, type of calculation to run, time range, and, optionally, any filters to use for drill-down into the data set that is returned by the query.

For pre-computed metrics, only simple calculations are needed, since the specific function used to perform the calculation is embedded in the metric.

To generate custom reports, you select a metric + function calculation to run over the specified dimensions.

The base request to create a custom report that calculates average response time for all APIs in an environment is:

/stats/apis?select=avg(total_response_time)

Use the additional query parameters defined in the API method to construct the complete request.

Filtering

Filters can be applied to custom resources. Custom resources are:

Symbol Operation
in for list inclusion
notin for list exclusion
eq =
ne != or
gt >
lt <
ge >=
le <=


Sample filters
Description Filter query structure
Stats for API proxies named either api1 or api2 filter=(apiproxy in 'api1','api2')
Stats for all API proxies except api1 and api2 filter=(apiproxy notin 'ap1','api2')
Stats where there are no errors filter=(iserror eq 0)
Stats where there is no error messages or the API proxy name is api1 or api2 filter=(iserror eq 1) or (apiproxy in 'api1','api2')
Stats where (response code is either 201 or 301) and (there are errors) or (API proxy name is either api1 or api2) filter=(responsecode le 201 or responsecode eq 301) and (iserror eq 1) or (apiproxy in 'api1','api2')


Sample Request:
$ curl -X GET -H "Accept:application/json" \
https://api.enterprise.apigee.com/v1/o/{org_name}/environments/{env_name}/stats/{dimension_name}?"select={metric_name}&timeRange=1/1/2013%2000:00~1/2/2013%2000:00&timeUnit=hour&sortby={metric_name}&sort=DESC&filter=(apiproxy%20in%20'weather','news')" \
-u myname:mypass

Query Parameters:
Name Description Default Required?
select Designates the metric to be aggregated for the report. Supported metrics are message_count, error_count, total_response_time, max_response_time, min_response_time, data_exchange_size, end_point_response_time N/A Yes
timeRange The start and end time for the desired interval. The date format is MM/DD/YYYY HH:MM. For example, 1/1/2013%2000:00~1/2/2013%2000:00 N/A Yes
timeUnit second, minute, hour, day, week, month, quarter, year, decade, century, millennium N/A Yes
sortby When two or more select values are specified, 'sortby' can be used to specify the select used for sorting results: message_count, error_count, total_response_time, max_response_time, min_response_time, data_exchange_size, end_point_response_time N/A No
sort Supported sort scopes are DESC or ASC N/A No
topk Take "top k" results from results, for example, to return the top 5 results "topk=5". N/A No
filter Enables drill-down on specific dimension values N/A No
limit Set the limit for the number of entries returned by the API N/A No
offset Use offset with limit to enable pagination of results. For example, to display results 11-20, set limit to '10' and offset to '10'. N/A No

realtime

Lets you obtain real-time query data. When set to true, queries return recently arrived API traffic data when the user-submitted time range for the query is less than one hour. If set to false, then queries are taken from the default cloud data store, which results a delay in the availability of query data of up to three hours. This parameter overrides the accuracy query parameter setting. 

 

false
No
accuracy Lets you specify that queries return data either from the raw (non-sampled) API traffic data store or from a sample of the raw API data. Queries against sampled data sets are smaller than the raw data set, and therefore run faster. You can specify the following values for the accuracy query parameter. 

 

  • accuracy=0: Retrieve query data from the raw API traffic.
  • accuracy=1 : Retrieve query data from the 1% sampled traffic table; that is, the table that is 1% in size of the raw traffic table.
  • accuracy=10: Retrieve query data from the 10% sampled traffic table; that is, the table that is 10% in size of the raw traffic table. 
Note that the realtime query parameter overrides this parameter. 
N/A No


Sample Response:
{
  "environments" : [ {
	"dimensions" : [ {
  	  "metrics" : [ 
                 {
    	        "name" : "message_count",
    	        "values" : [ {
      	           "timestamp" : 1335241800000,
      	           "value" : "1.0"
    	         } ]
  	      } ,
                 {
    	         "name" : "error_count",
    	         "values" : [ {
      	            "timestamp" : 1335241800000,
      	            "value" : "0.0"
    	           } ]
  	    } 
              ],
  	
               "name" : "api1"
	}, 
            {
  	  "metrics" : [ 
               {
    	      "name" : "message_count",
    	      "values" : [ {
      	             "timestamp" : 1335241800000,
      	             "value" : "1.0"
    	          } ]
  	     },
                {
    	        "name" : "error_count",
    	        "values" : [ {
      	              "timestamp" : 1335241800000,
      	              "value" : "0.0"
    	        } ]
  	    } 
             ],
  	
             "name" : "api2"
	} 
          ],
        
         "name" : "test"
      } 
    ],
   "metaData" : {
    }
}

Response Payload Elements:
Name Description
metadata Metadata associated with the report
environments Environments in the organization where the statistics are collected (supports wildcard * for cross environment statistics collection)
metrics The values returned for the specified dimension
dimensions The dimension defined for measurement: in this example api_name.
metrics Metrics for the report

 

Help or comments?

  • Something's not working: See Apigee Support
  • Something's wrong with the docs: Click Send Feedback in the lower right.
    (Incorrect? Unclear? Broken link? Typo?)