ves-io-schema-network_policy-CustomDataAPI-NetworkPolicyHits

Examples of performing network_policy CustomDataAPI NetworkPolicyHits

Usecase:

Get Network Policy hits

Request:

Request using vesctl:

vesctl request rpc network_policy.CustomDataAPI.NetworkPolicyHits -i request.yaml --uri /public/namespaces/system/network_policy/hits --http-method POST

where file request.yaml has following contents:

endTime: "1593622800"
groupBy:
- POLICY_RULE
- SITE
labelFilter:
- label: POLICY
  value: policy-1
namespace: system
startTime: "1593619200"

vesctl yaml response:

data:
- id:
    policyRule: rule-1
    site: site-1
  metric:
  - timestamp: 1593622800
    value: "100"
- id:
    policyRule: rule-1
    site: site-2
  metric:
  - timestamp: 1593622800
    value: "50"

Request using curl:

curl -X 'POST' -d '{"namespace":"system","labelFilter":[{"label":"POLICY","value":"policy-1"}],"groupBy":["POLICY_RULE","SITE"],"startTime":"1593619200","endTime":"1593622800"}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build186851157_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/data/namespaces/system/network_policy/hits'

curl response:

HTTP/1.1 200 OK
Content-Length: 607
Content-Type: application/json
Date: Tue, 24 Nov 2020 10:46:36 GMT
Vary: Accept-Encoding

{
  "data": [
    {
      "id": {
        "namespace": "",
        "policy": "",
        "policy_set": "",
        "policy_rule": "rule-1",
        "action": "",
        "site": "site-1"
      },
      "metric": [
        {
          "timestamp": 1593622800,
          "value": "100"
        }
      ]
    },
    {
      "id": {
        "namespace": "",
        "policy": "",
        "policy_set": "",
        "policy_rule": "rule-1",
        "action": "",
        "site": "site-2"
      },
      "metric": [
        {
          "timestamp": 1593622800,
          "value": "50"
        }
      ]
    }
  ]
}