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
        subAggs: {}
      - count: "230"
        key: GB
        subAggs: {}
      - count: "45"
        key: JP
        subAggs: {}
  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\"}","start_time":"1591120800","end_time":"1591131600","aggs":{"country":{"field_aggregation":{"field":"COUNTRY","topk":3}},"date_histogram":{"date_aggregation":{"step":"1h"}},"unique_visitors":{"cardinality_aggregation":{"field":"VISITOR_ID"}}}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_var_folders_2__8qnt6fwd5dvglr1xqq6l8b7w0000gp_T_go-build3109416560_b001_apidocs.test/host=C02FN35BMD6R/svc=S:examplesvc/site=mytestce01' 'https://acmecorp.console.ves.volterra.io/api/data/namespaces/ns1/access_logs/aggregation'
        

curl response:

          HTTP/1.1 200 OK
Content-Type: application/json
Date: Thu, 21 Mar 2024 14:06:00 GMT
Vary: Accept-Encoding

{
  "total_hits": "1282",
  "aggs": {
    "country": {
      "date_aggregation": null,
      "field_aggregation": {
        "buckets": [
          {
            "key": "US",
            "count": "456",
            "sub_aggs": {
            },
            "trend_value": null,
            "order_by": null
          },
          {
            "key": "GB",
            "count": "230",
            "sub_aggs": {
            },
            "trend_value": null,
            "order_by": null
          },
          {
            "key": "JP",
            "count": "45",
            "sub_aggs": {
            },
            "trend_value": null,
            "order_by": null
          }
        ]
      },
      "multi_field_aggregation": null,
      "cardinality_aggregation": null,
      "metrics_aggregation": null
    },
    "date_histogram": {
      "date_aggregation": {
        "buckets": [
          {
            "time": "1591120800000",
            "count": "224",
            "sub_aggs": {
            },
            "trend_value": null
          },
          {
            "time": "1591124400000",
            "count": "533",
            "sub_aggs": {
            },
            "trend_value": null
          },
          {
            "time": "1591128000000",
            "count": "525",
            "sub_aggs": {
            },
            "trend_value": null
          }
        ],
        "step": ""
      },
      "field_aggregation": null,
      "multi_field_aggregation": null,
      "cardinality_aggregation": null,
      "metrics_aggregation": null
    },
    "unique_visitors": {
      "date_aggregation": null,
      "field_aggregation": null,
      "multi_field_aggregation": null,
      "cardinality_aggregation": {
        "count": "100",
        "trend_value": null
      },
      "metrics_aggregation": null
    }
  }
}