ves-io-schema-log-CustomAPI-VK8SEventsQuery

Examples of performing log CustomAPI VK8SEventsQuery

Usecase:

vK8s events query for Pod in namespace ns1

Request:

Request using vesctl:

vesctl request rpc log.CustomAPI.VK8SEventsQuery -i request.yaml --uri /public/namespaces/ns1/vk8s_events --http-method POST

where file request.yaml has following contents:

endTime: "2020-09-23T12:00:00Z"
query: '{involvedObject.kind="Pod"}'
startTime: "2020-09-23T11:00:00Z"

vesctl yaml response:

aggs: {}
logs:
- |
  {"metadata":{"name":"nginx-deployment-68c579b65-hcpsx.1635f367cbdee341","namespace":"tenant1--ns1","selfLink":"/api/v1/namespaces/tenant1--ns1/events/nginx-deployment-68c579b65-hcpsx.1635f367cbdee341","uid":"235b491b-5fe3-4c2f-bd5f-3a9c40c9b9e2","resourceVersion":"60678600","creationTimestamp":"2020-09-23T11:14:34Z"},"reason":"Pulling","message":"Pulling image "nginx:1.14.2"","source":{"component":"kubelet","host":"master-0"},"firstTimestamp":"2020-09-18T18:14:29Z","lastTimestamp":"2020-09-23T11:14:34Z","count":1325,"type":"Normal","eventTime":null,"reportingComponent":"","reportingInstance":"","involvedObject":{"kind":"Pod","namespace":"tenant1--ns1","name":"nginx-deployment-68c579b65-hcpsx","uid":"57700394-0f41-41b1-8b15-20d1db730357","apiVersion":"v1","resourceVersion":"59764380","fieldPath":"spec.containers{nginx}","labels":{"app":"nginx","pod-template-hash":"68c579b65","ves.io/workload":"nginx-deployment","ves.io/workload-type":"k8s.io.api.apps.v1.Deployment"}}}
- |
  {"metadata":{"name":"nginx-deployment-68c579b65-hcpsx.1635f3685a6ae3c8","namespace":"tenant1--ns1","selfLink":"/api/v1/namespaces/tenant1--ns1/events/nginx-deployment-68c579b65-hcpsx.1635f3685a6ae3c8","uid":"cb571602-1794-4db6-b070-9cdfbb9bf703","resourceVersion":"60652438","creationTimestamp":"2020-09-23T07:59:29Z"},"reason":"Started","message":"Started container nginx","source":{"component":"kubelet","host":"master-0"},"firstTimestamp":"2020-09-18T18:14:32Z","lastTimestamp":"2020-09-23T11:11:29Z","count":1287,"type":"Normal","eventTime":null,"reportingComponent":"","reportingInstance":"","involvedObject":{"kind":"Pod","namespace":"tenant1--ns1","name":"nginx-deployment-68c579b65-hcpsx","uid":"57700394-0f41-41b1-8b15-20d1db730357","apiVersion":"v1","resourceVersion":"59764380","fieldPath":"spec.containers{nginx}","labels":{"app":"nginx","pod-template-hash":"68c579b65","ves.io/workload":"nginx-deployment","ves.io/workload-type":"k8s.io.api.apps.v1.Deployment"}}}
totalHits: "2"

Request using curl:

curl -X 'POST' -d '{"query":"{involvedObject.kind="Pod"}","startTime":"2020-09-23T11:00:00Z","endTime":"2020-09-23T12:00:00Z"}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build185306297_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/data/namespaces/ns1/vk8s_events'

curl response:

HTTP/1.1 200 OK
Content-Type: application/json
Date: Mon, 19 Oct 2020 09:48:40 GMT
Vary: Accept-Encoding

{
  "logs": [
    "{"metadata":{"name":"nginx-deployment-68c579b65-hcpsx.1635f367cbdee341","namespace":"tenant1--ns1","selfLink":"/api/v1/namespaces/tenant1--ns1/events/nginx-deployment-68c579b65-hcpsx.1635f367cbdee341","uid":"235b491b-5fe3-4c2f-bd5f-3a9c40c9b9e2","resourceVersion":"60678600","creationTimestamp":"2020-09-23T11:14:34Z"},"reason":"Pulling","message":"Pulling image \"nginx:1.14.2\"","source":{"component":"kubelet","host":"master-0"},"firstTimestamp":"2020-09-18T18:14:29Z","lastTimestamp":"2020-09-23T11:14:34Z","count":1325,"type":"Normal","eventTime":null,"reportingComponent":"","reportingInstance":"","involvedObject":{"kind":"Pod","namespace":"tenant1--ns1","name":"nginx-deployment-68c579b65-hcpsx","uid":"57700394-0f41-41b1-8b15-20d1db730357","apiVersion":"v1","resourceVersion":"59764380","fieldPath":"spec.containers{nginx}","labels":{"app":"nginx","pod-template-hash":"68c579b65","ves.io/workload":"nginx-deployment","ves.io/workload-type":"k8s.io.api.apps.v1.Deployment"}}}
",
    "{"metadata":{"name":"nginx-deployment-68c579b65-hcpsx.1635f3685a6ae3c8","namespace":"tenant1--ns1","selfLink":"/api/v1/namespaces/tenant1--ns1/events/nginx-deployment-68c579b65-hcpsx.1635f3685a6ae3c8","uid":"cb571602-1794-4db6-b070-9cdfbb9bf703","resourceVersion":"60652438","creationTimestamp":"2020-09-23T07:59:29Z"},"reason":"Started","message":"Started container nginx","source":{"component":"kubelet","host":"master-0"},"firstTimestamp":"2020-09-18T18:14:32Z","lastTimestamp":"2020-09-23T11:11:29Z","count":1287,"type":"Normal","eventTime":null,"reportingComponent":"","reportingInstance":"","involvedObject":{"kind":"Pod","namespace":"tenant1--ns1","name":"nginx-deployment-68c579b65-hcpsx","uid":"57700394-0f41-41b1-8b15-20d1db730357","apiVersion":"v1","resourceVersion":"59764380","fieldPath":"spec.containers{nginx}","labels":{"app":"nginx","pod-template-hash":"68c579b65","ves.io/workload":"nginx-deployment","ves.io/workload-type":"k8s.io.api.apps.v1.Deployment"}}}
"
  ],
  "total_hits": "2",
  "aggs": {
  },
  "scroll_id": ""
}