Query usage events
Changed onReturns totals over the organization's usage events in a time range, grouped by up to 2 dimensions and optionally split into calendar buckets. Groups come largest reported_cost first unless the request sets sort. For a caller whose access covers only particular principals or groups, the operation reads only the events of those principals and groups.
The operation doesn't change anything; the query goes in the body because it can be large. Each page holds page.size groups with their complete series. To read the next or previous page, a client sends the response's meta.page.next or meta.page.previous cursor back as page.after or page.before in an otherwise identical body.
The totals come from the same stored events as the usage event list and budget balances, so a query and a budget balance over the same scope and range report the same numbers. A redelivered copy of an event counts in the totals until it is merged into the stored event, so for a short time the totals can exceed the usage event list.
Request
- Base URLhttps://global.api.konghq.com
- Auth
- HTTP bearer
- or HTTP bearer
- or HTTP bearer
- or HTTP bearer
Request body
The start of the time range, as an RFC 3339 timestamp. Events whose time is at or after starts_at count.
The end of the time range, as an RFC 3339 timestamp after starts_at. Events whose time is before ends_at count.
Splits each group's totals into time buckets of this calendar interval, returned in series:
- PT1H: an hour.
- P1D: a day.
- P1W: an ISO week, starting on Monday.
- P1M: a calendar month.
Bucket boundaries follow the calendar in time_zone, so the first and last buckets can extend beyond starts_at and ends_at. The range can span at most 400 buckets. Without granularity, each group has only its totals for the whole range, and series is empty.
The IANA time zone whose calendar sets the bucket boundaries.
The name must be spelled as the time zone database spells it, such as Europe/Budapest, not europe/budapest. Offsets such as +02:00 aren't accepted. Defaults to UTC.
The dimensions to group the events by. Each group gets its own totals. An event without a value for a dimension goes into that dimension's null group, so unattributed usage is the null group of subject. With group or team, an event counts fully under each of its groups or teams, so their totals can add up to more than the events' overall total. Without dimensions, the response has a single group.
At most 2 dimensions, each named once, from subject, subject_id, subject_type, provider, model, model_id, request_mode, region, client, source, group, team, service_id, route_id, consumer_id, application_id, tags.<key>. tags.<key> groups by the value of one tag.
The totals to compute for each group and bucket.
At least 1 measure, each named once. Defaults to every measure except subjects.
subjects counts the distinct non-empty subjects in each group. It needs a request without granularity, in measures and in sort. It isn't additive across groups: a subject whose events fall in two groups counts once in each.
Narrows the events to aggregate. Each key names a field, its value is a filter object, and all the filters must match. A filter object carries exactly one operator:
- String fields take eq, neq, in, nin, contains, ncontains, exists, and, and or.
- Gateway ID fields take eq, neq, in, nin, exists, and, and or.
- groups, teams, and consumer_group_ids take has, has_any, nhas, nhas_any, exists, and, and or.
A key of the form tags.<key> filters on the value of that tag, and each value it compares has at most 256 characters, none of them a control character. Group filters compare complete group references, principal/{uuid}, consumer_group/{uuid}, or oidc/{group}, and an OIDC group must match in text and case. Team filters compare complete team references, principal/{uuid}. eq, neq, in, and nin compare strings case-sensitively, and contains and ncontains ignore case. Gateway IDs compare case-insensitively.
time, reported_cost, and tokens can't be filtered here, and starts_at and ends_at set the time range instead. A key that names one of them, or an unknown field, isn't accepted.
The order of the groups, as sort keys in priority order. A key names a measure, which sorts the groups by their total over the whole range, or a requested dimension. The service adds the requested dimensions, ascending, as tiebreakers so the order is unique, and null dimension values sort last.
At least 1 key, each naming a different field. Defaults to reported_cost in desc order.
Selects a page of groups and its size.
A request can't set both after and before, and a cursor that doesn't match the request's sort isn't accepted.
Response
A page of groups with their totals.
The groups on this page, in sort order.
Information about the page.
Changes
- info
endpoint added
- info