List usage events
Changed onReturns a page of the organization's usage events, newest first unless the request sets sort. The list includes usage from the gateway and usage reported with POST /v1/ai-cost-management/events, each in the ai.usage.v1 form that producers report. For a caller whose access covers only particular principals or groups, the operation reads only the events of those principals and groups.
The service may return fewer events than requested when the page reaches its byte budget. Follow the page links to continue.
Listed events differ from what producers send:
- arrival isn't included, though filter[arrival]=late selects late events.
- A quantity or cost the producer didn't report shows as "0".
- datacontenttype, dataschema, and provenance keys other than the ones this schema lists are left out.
Request
- Base URLhttps://global.api.konghq.com
- Auth
- HTTP bearer
- or HTTP bearer
- or HTTP bearer
- or HTTP bearer
Query parameters
Filters on the usage events' fields. Every filter must match, and a bare value means eq.
- source, subject_type, request_mode, provider, model, model_id, region, client: eq, neq, oeq, contains, and ocontains.
- subject, subject_id: eq, neq, oeq, contains, ocontains, exists, and nexists. exists and nexists take no value, and filter[subject][nexists] selects unattributed usage.
- service_id, route_id, consumer_id, application_id: eq, neq, and oeq, with gateway IDs.
- consumer_group_ids, groups, teams: eq and oeq, which match an event whose list contains the value, or any of the values. Groups are complete group references, principal/{uuid}, consumer_group/{uuid}, or oidc/{group}, and an OIDC group must match in text and case. Teams are complete team references, principal/{uuid}. The {uuid} in a reference is never the nil UUID. Consumer group IDs are gateway IDs, any 8-4-4-4-12 hexadecimal value, compared ignoring case.
- time: eq, gt, gte, lt, and lte, with RFC 3339 timestamps.
- reported_cost: eq, gt, gte, lt, and lte, which compare the cost's value with an exact decimal string from 0 to 999999999.999999999. 0 also matches events whose producer omitted the cost, because a missing cost is stored as zero.
- tokens: exists and nexists, which take no value. An event has tokens when it reports a positive quantity of any token kind other than reported_total_tokens. With filter[reported_cost][eq]=0, filter[tokens][exists] selects the unpriced events.
- arrival: eq, neq, and oeq, with late or on_time. An event is late when it reached the service more than 1 hour after its time.
- tags.<key>: eq, neq, oeq, contains, ocontains, exists, and nexists. A bare key with no value, as in filter[tags.env], matches events that have the tag, and eq with an empty value matches events without it. Each value, including each part of an oeq or ocontains list, has at most 256 characters, none of them a control character.
Any other filter key fails with 400. eq, neq, and oeq compare strings case-sensitively, and contains and ocontains ignore case. Gateway IDs compare case-insensitively.
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filters on the given datetime (RFC-3339) field value.
Filters a decimal field by an exact value or a range. Values compare as exact decimals, without rounding. Filters on the same field must all match, so a lower and an upper bound together select an interval.
Filters a field only by whether it has a value, with exists or nexists. Neither operator takes a value.
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filter using one of the following operators: eq, oeq, neq, contains, ocontains
Filter using one of the following operators: eq, oeq, neq
Filter using one of the following operators: eq, oeq, neq
Filter using one of the following operators: eq, oeq, neq
Filter using one of the following operators: eq, oeq
Filter using one of the following operators: eq, oeq
Filter using one of the following operators: eq, oeq
Filter using one of the following operators: eq, oeq, neq
Filters a field by its value with eq, neq, or oeq. Accepts on_time and late. A bare value means eq.
Narrows the list. Each filter has the form filter[field][operator]=value, or filter[field]=value for eq. An operator that takes no value, such as exists, leaves out =value.
A request can combine several filters, and every filter must match.
{
"time": {
"eq": "2022-03-30T07:20:50Z"
}
}The order of the results, as a comma-separated list of fields in priority order. Each field can be followed by a space and asc or desc, and sorts in ascending order without one. The service breaks ties so that the order is unique.
Sortable fields: source, subject_type, subject, subject_id, request_mode, time, reported_cost, provider, model, model_id, region, client, service_id, route_id, consumer_id, application_id. Defaults to time desc.
The number of results on each page.
1 to 100. Defaults to 20.
A cursor for the page after an earlier response's page. Clients take it from that response's meta.page.next link, which also carries the request's other parameters, and don't build or change it.
A request can't send both page[after] and page[before].
A cursor for the page before an earlier response's page. Clients take it from that response's meta.page.previous link, which also carries the request's other parameters, and don't build or change it.
A request can't send both page[after] and page[before].
Response
A page of usage events.
The usage events on this page, in sort order. Each has the ai.usage.v1 form that producers report.
Pagination metadata.
Example response
{
"meta": {
"page": {
"size": 10
}
}
}Changes
- info
endpoint added
- info