Aggregate Usage Metrics
client.Admin.UsageMetrics.Aggregate(ctx, query) (*AdminUsageMetricAggregateResponse, error)
GET/api/v1/admin/usage-metrics/aggregate
Aggregate usage metrics by one or more dimensions, reporting total credits used. Global admin only.
A date range is required, which bounds the scan via the day-leading index. Supplying organization_id narrows it further via the (organization_id, day) index.
Supported group_by dimensions: day, organization_id, project_id, event_type, user_id. Buckets are ordered by total credits descending.
Aggregate Usage Metrics
package main
import (
"context"
"fmt"
"github.com/run-llama/llamacloud-admin-go"
"github.com/run-llama/llamacloud-admin-go/option"
)
func main() {
client := llamacloudadmin.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Admin.UsageMetrics.Aggregate(context.TODO(), llamacloudadmin.AdminUsageMetricAggregateParams{
DayOnOrAfter: "day_on_or_after",
DayOnOrBefore: "day_on_or_before",
GroupBy: []string{"string"},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Buckets)
}
{
"buckets": [
{
"dimensions": {
"foo": "string"
},
"metric_count": 0,
"total_credits": 0,
"total_value": 0
}
],
"group_by": [
"day"
]
}Returns Examples
{
"buckets": [
{
"dimensions": {
"foo": "string"
},
"metric_count": 0,
"total_credits": 0,
"total_value": 0
}
],
"group_by": [
"day"
]
}