ves-io-schema-log-CustomAPI-AccessLogAggregationQuery
Examples of performing log CustomAPI AccessLogAggregationQuery
Usecase:
Access Log Aggregation query for virtual host vhost1
in namespace ns1
Request:
Request using vesctl:
vesctl request rpc log.CustomAPI.AccessLogAggregationQuery -i request.yaml --uri /public/namespaces/ns1/access_logs/aggregation --http-method POST
where file request.yaml has following contents:
aggs:
country:
fieldAggregation:
field: COUNTRY
topk: 3
date_histogram:
dateAggregation:
step: 1h
unique_visitors:
cardinalityAggregation:
field: VISITOR_ID
endTime: "1591131600"
query: '{vh_name="vhost1"}'
startTime: "1591120800"
vesctl yaml response:
aggs:
country:
fieldAggregation:
buckets:
- count: "456"
key: US
- count: "230"
key: GB
- count: "45"
key: JP
date_histogram:
dateAggregation:
buckets:
- count: "224"
subAggs: {}
time: "1591120800000"
- count: "533"
subAggs: {}
time: "1591124400000"
- count: "525"
subAggs: {}
time: "1591128000000"
unique_visitors:
cardinalityAggregation:
count: "100"
totalHits: "1282"
Request using curl:
curl -X 'POST' -d '{"query":"{vh_name="vhost1"}","startTime":"1591120800","endTime":"1591131600","aggs":{"country":{"fieldAggregation":{"field":"COUNTRY","topk":3}},"date_histogram":{"dateAggregation":{"step":"1h"}},"unique_visitors":{"cardinalityAggregation":{"field":"VISITOR_ID"}}}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build318584715_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/data/namespaces/ns1/access_logs/aggregation'
curl response:
HTTP/1.1 200 OK
Content-Length: 1156
Content-Type: application/json
Date: Wed, 31 Mar 2021 08:29:11 GMT
Vary: Accept-Encoding
{
"total_hits": "1282",
"aggs": {
"country": {
"date_aggregation": null,
"field_aggregation": {
"buckets": [
{
"key": "US",
"count": "456"
},
{
"key": "GB",
"count": "230"
},
{
"key": "JP",
"count": "45"
}
]
},
"cardinality_aggregation": null
},
"date_histogram": {
"date_aggregation": {
"buckets": [
{
"time": "1591120800000",
"count": "224",
"sub_aggs": {
}
},
{
"time": "1591124400000",
"count": "533",
"sub_aggs": {
}
},
{
"time": "1591128000000",
"count": "525",
"sub_aggs": {
}
}
]
},
"field_aggregation": null,
"cardinality_aggregation": null
},
"unique_visitors": {
"date_aggregation": null,
"field_aggregation": null,
"cardinality_aggregation": {
"count": "100"
}
}
}
}