Skip to content

Latest commit

 

History

History
101 lines (94 loc) · 3.32 KB

metrics.md

File metadata and controls

101 lines (94 loc) · 3.32 KB

Get node stats from apiserver api

curl -k http://localhost:4194/api/v2.1/storage | python -m json.tool
curl -k https://localhost:10250/stats/summary (The value node.memory.availableBytes which is what drives eviction.)
kubectl/oc get --raw /api/v1/nodes/${nodename}/proxy/stats/summary

Get metrics from haepster in OpenShift

/apis/metrics/v1alpha1/namespaces/{ns}/pods/?labelSelector="{label}"

oadm policy add-cluster-role-to-user cluster-admin $user
token=`oc whoami -t`
token=rvSA594JdSeRx0ZCMMonqCQIg7J-Bc1DhGE9E70Elb0

[root@qe-dma1-master-1 ~]# curl -k -H "Authorization: Bearer $token" -X GET https://qe-dma1-master-1.0210-tte.qe.rhcloud.com:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/apis/metrics/v1alpha1/namespaces/dma1/pods/
{
  "metadata": {},
  "items": [
   {
    "metadata": {
     "name": "hello-pod",
     "namespace": "dma1",
     "creationTimestamp": "2017-02-10T07:40:47Z"
    },
    "timestamp": "2017-02-10T07:40:30Z",
    "window": "1m0s",
    "containers": [
     {
      "name": "hello-pod",
      "usage": {
       "cpu": "0",
       "memory": "936Ki"
      }
     }
    ]
   },
   {
    "metadata": {
     "name": "resource-consumer-1-3b8dw",
     "namespace": "dma1",
     "creationTimestamp": "2017-02-10T07:40:47Z"
    },
    "timestamp": "2017-02-10T07:40:30Z",
    "window": "1m0s",
    "containers": [
     {
      "name": "resource-consumer",
      "usage": {
       "cpu": "0",
       "memory": "1788Ki"
      }
     }
    ]
   }
  ]
 }
 //Get selector pods metrics
$ curl -k -H "Authorization: Bearer $token" -X GET https://qe-dma1-master-1.0210-tte.qe.rhcloud.com:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/apis/metrics/v1alpha1/namespaces/dma1/pods/?labelSelector="name=hello-pod"
{
  "metadata": {},
  "items": [
   {
    "metadata": {
     "name": "hello-pod",
     "namespace": "dma1",
     "creationTimestamp": "2017-02-10T07:40:49Z"
    },
    "timestamp": "2017-02-10T07:40:30Z",
    "window": "1m0s",
    "containers": [
     {
      "name": "hello-pod",
      "usage": {
       "cpu": "0",
       "memory": "936Ki"
      }
     }
    ]
   }
  ]
 }[root@qe-dma1-master-1 ~]# 

/api/v1/model/namespaces/{ns}/pods/{pod}/metrics/{metrics}

oadm policy add-cluster-role-to-user cluster-admin $user
token=`oc whoami -t`
token=rvSA594JdSeRx0ZCMMonqCQIg7J-Bc1DhGE9E70Elb0
//Get pod list
curl -k -H "Authorization: Bearer $token" -X GET https://qe-dma1-master-1.0210-tte.qe.rhcloud.com:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/namespaces/dma1/pods/
//Get metrics list
curl -k -H "Authorization: Bearer $token" -X GET https://qe-dma1-master-1.0210-tte.qe.rhcloud.com:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/namespaces/dma1/pods/resource-consumer-1-3b8dw/metrics/
//Get cpu metrics
curl -k -H "Authorization: Bearer $token" -X GET  https://qe-dma1-master-1.0210-tte.qe.rhcloud.com:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/namespaces/dma1/pods/resource-consumer-1-3b8dw/metrics/cpu/usage_rate