Method: organizations.environments.queries.create

Submit a query to be processed in the background. If the submission of the query succeeds, the API returns a 201 status and an ID that refer to the query. In addition to the HTTP status 201, the state of "enqueued" means that the request succeeded.

HTTP request

POST https://apigee.googleapis.com/v1/{parent=organizations/*/environments/*}/queries

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
parent

string

Required. The parent organization and environment names. Must be of the form organizations/{org}/environments/{env}.

Request body

The request body contains an instance of Query.

Response body

If successful, the response body contains a newly created instance of AsyncQuery.

Authorization Scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/cloud-platform

Query

JSON representation
{
  "metrics": [
    {
      object (Metric)
    }
  ],
  "dimensions": [
    string
  ],
  "timeRange": value,
  "filter": string,
  "groupByTimeUnit": string,
  "limit": number,
  "outputFormat": string,
  "csvDelimiter": string,
  "reportDefinitionId": string
}
Fields
metrics[]

object (Metric)

A list of Metrics

dimensions[]

string

A list of dimensions https://docs.apigee.com/api-platform/analytics/analytics-reference#dimensions

timeRange

value (Value format)

Required. Time range for the query. Can use the following predefined strings to specify the time range: last60minutes last24hours last7days Or, specify the timeRange as a structure describing start and end timestamps in the ISO format: yyyy-mm-ddThh:mm:ssZ.

Example: "timeRange": { "start": "2018-07-29T00:13:00Z", "end": "2018-08-01T00:18:00Z" }

filter

string

Boolean expression that can be used to filter data. Filter expressions can be combined using AND/OR terms and should be fully parenthesized to avoid ambiguity. See Analytics metrics, dimensions, and filters reference https://docs.apigee.com/api-platform/analytics/analytics-reference for more information on the fields available to filter on. For more information on the tokens that you use to build filter expressions, see Filter expression syntax. https://docs.apigee.com/api-platform/analytics/asynch-reports-api#filter-expression-syntax

groupByTimeUnit

string

Time unit used to group the result set. Valid values include: second, minute, hour, day, week, or month. If a query includes groupByTimeUnit, then the result is an aggregation based on the specified time unit and the resultant timestamp does not include milliseconds precision. If a query omits groupByTimeUnit, then the resultant timestamp includes milliseconds precision.

limit

number

Maximum number of rows that can be returned in the result.

outputFormat

string

Valid values include: csv or json. Defaults to json. Note: Configure the delimiter for CSV output using the csvDelimiter property.

csvDelimiter

string

Delimiter used in the CSV file, if outputFormat is set to csv. Defaults to the , (comma) character. Supported delimiter characters include comma (,), pipe (|), and tab (\t).

reportDefinitionId

string

Asynchronous Report ID.

Metric

More info about Metric: https://docs.apigee.com/api-platform/analytics/analytics-reference#metrics

JSON representation
{
  "name": string,
  "function": string,
  "alias": string,
  "operator": string,
  "value": string
}
Fields
name

string

Required. Metric name

function

string

Aggregation function: avg, min, max, or sum

alias

string

Alias for the metric. Alias will be used to replace metric name in query results.

operator

string

One of +, -, /, %, *

value

string

Operand value should be provided when operator is set.