ves-io-schema-views-workload-CustomDataAPI-Usage

Examples of performing views_workload CustomDataAPI Usage

Usecase:

Get workload usage

Request:

Request using vesctl:

vesctl request rpc views_workload.CustomDataAPI.Usage -i request.yaml --uri /public/namespaces/documentation/workloads/usage --http-method POST

where file request.yaml has following contents:

endTime: "1593622800"
fieldSelector:
- CPU_USAGE
- MEMORY_USAGE
filter: '{POD="adservice"}'
groupBy:
- POD
- SITE
namespace: documentation
startTime: "1593619200"

vesctl yaml response:

data:
- data:
  - key:
      POD: adservice
      SITE: site-1
    value:
    - timestamp: 1593622800
      value: "0.1"
  - key:
      POD: adservice
      SITE: site-2
    value:
    - timestamp: 1593622800
      value: "0.01"
- data:
  - key:
      POD: adservice
      SITE: site-1
    value:
    - timestamp: 1593622800
      value: "10485760"
  - key:
      POD: adservice
      SITE: site-2
    value:
    - timestamp: 1593622800
      value: "26214400"
  type: MEMORY_USAGE

Request using curl:

curl -X 'POST' -d '{"namespace":"documentation","filter":"{POD="adservice"}","groupBy":["POD","SITE"],"fieldSelector":["CPU_USAGE","MEMORY_USAGE"],"startTime":"1593619200","endTime":"1593622800"}' -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/documentation/workloads/usage'

curl response:

HTTP/1.1 200 OK
Content-Length: 1130
Content-Type: application/json
Date: Mon, 19 Oct 2020 09:49:35 GMT
Vary: Accept-Encoding

{
  "data": [
    {
      "type": "CPU_USAGE",
      "data": [
        {
          "key": {
            "POD": "adservice",
            "SITE": "site-1"
          },
          "value": [
            {
              "timestamp": 1593622800,
              "value": "0.1"
            }
          ]
        },
        {
          "key": {
            "POD": "adservice",
            "SITE": "site-2"
          },
          "value": [
            {
              "timestamp": 1593622800,
              "value": "0.01"
            }
          ]
        }
      ]
    },
    {
      "type": "MEMORY_USAGE",
      "data": [
        {
          "key": {
            "POD": "adservice",
            "SITE": "site-1"
          },
          "value": [
            {
              "timestamp": 1593622800,
              "value": "10485760"
            }
          ]
        },
        {
          "key": {
            "POD": "adservice",
            "SITE": "site-2"
          },
          "value": [
            {
              "timestamp": 1593622800,
              "value": "26214400"
            }
          ]
        }
      ]
    }
  ]
}