ves-io-schema-log-CustomAPI-K8SEventsAggregationQuery

Examples of performing log CustomAPI K8SEventsAggregationQuery

Usecase:

K8s events Aggregation query for Pod in namespace ns1

Request:

Request using vesctl:

vesctl request rpc log.CustomAPI.K8SEventsAggregationQuery -i request.yaml --uri /public/namespaces/ns1/site/site-1/k8s_events/aggregation --http-method POST

where file request.yaml has following contents:

aggs:
  date_histogram:
    dateAggregation:
      step: 1h
  pod:
    fieldAggregation:
      field: INVOLVED_OBJECT_NAME
      topk: 3
endTime: "1591131600"
query: '{involvedObject.kind="Pod"}'
startTime: "1591120800"

vesctl yaml response:

aggs:
  date_histogram:
    dateAggregation:
      buckets:
      - count: "224"
        subAggs: {}
        time: "1591120800000"
      - count: "533"
        subAggs: {}
        time: "1591124400000"
      - count: "525"
        subAggs: {}
        time: "1591128000000"
  pod:
    fieldAggregation:
      buckets:
      - count: "456"
        key: pod-1
      - count: "230"
        key: pod-2
      - count: "45"
        key: pod-3
totalHits: "1282"

Request using curl:

curl -X 'POST' -d '{"query":"{involvedObject.kind="Pod"}","startTime":"1591120800","endTime":"1591131600","aggs":{"date_histogram":{"dateAggregation":{"step":"1h"}},"pod":{"fieldAggregation":{"field":"INVOLVED_OBJECT_NAME","topk":3}}}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build817539475_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/data/namespaces/ns1/site/site-1/k8s_events/aggregation'

curl response:

HTTP/1.1 200 OK
Content-Length: 998
Content-Type: application/json
Date: Mon, 22 Feb 2021 15:44:13 GMT
Vary: Accept-Encoding

{
  "total_hits": "1282",
  "aggs": {
    "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
    },
    "pod": {
      "date_aggregation": null,
      "field_aggregation": {
        "buckets": [
          {
            "key": "pod-1",
            "count": "456"
          },
          {
            "key": "pod-2",
            "count": "230"
          },
          {
            "key": "pod-3",
            "count": "45"
          }
        ]
      },
      "cardinality_aggregation": null
    }
  }
}