2016-09-21 133 views
0

我目前有一個配置有Heapster/InfluxDB/Grafana的Kubernetes集羣。cAdvisor使用heapster格式的自定義指標

我知道Kubelet現在有一個嵌入式cAdvisor實例,我已將其配置爲查看應用程序端點以收集自定義指標。

我遵循這個指南:http://guoshimin.github.io/2016/06/03/custom-metrics.html

{ 
    "endpoint" : "http://localhost:31234/sessions", 
    "metrics_config" : [ 
    { 
     "name" : "activeSessions", 
     "metric_type" : "gauge", 
     "units" : "number of active sessions", 
     "data_type" : "int", 
     "polling_frequency" : 10, 
     "regex" : "Active sessions: ([0-9]+)" 
    } 
    ] 
} 

目前Kubelet拋出錯誤 -

failed to create collector for container "/docker/664af6c4c1998514770371267ba6c117c532a448f6301f14fc53ca9798abff5b", config "prometheus": json: cannot unmarshal object into Go value of type string 

它似乎認爲我使用的是普羅米修斯的配置。我應該使用不同的格式來收集指標並將它們傳遞給Heapster,因爲我的設置中沒有Prometheus?

回答

2

Kubernetes目前僅支持以Prometheus格式收集自定義指標。您的配置適用於通用收集器,因此prometheus收集器無法解析它。

作爲一個實驗,您可以手動將在主機上運行的容器上的docker標籤從io.cadvisor.metric.prometheus更改爲io.cadvisor.metric.raw,它應該可以工作。雖然Kubernetes沒有自動執行此操作的機制。

一旦cAdvisor刮掉了自定義指標,它們就會以Heapster能夠理解的格式導出。只要cAdvisor能夠獲得指標,Heapster就可以從cAdvisor獲取指標。