IaaS, PaaS, SaaS
Heapster
- クラスターワイドのアグリゲーター
- モニタリングデータ
- イベントデータ
- Kubernetesをネイティブサポート
- Podとして動作する
- Kubernetesで動作する他のアプリケーションと同じ
- クラスタで1つ動いている≠Node毎、コンテナ毎
- GKEではnamespace kube-systemにdeploymentがある
- ns: kube-system
- deployment: heapster-v1.5.0
- pod: heapster-v1.5.0-xxxx
- container: heapster
- container: prom-to-sd (prometheus to stackdriver)
- container: heapster-nanny
- GKEではnamespace kube-systemにdeploymentがある
- Cluster内の全てのNodeをdiscover
- 各Nodeのkubeletを通じてcAdvisorからメトリクスを収集
- 収集したメトリクスは関連するLabelと一緒にPodでまとめられる
- メトリクスを保存するためのバックエンドが必要
- InfluxDBが使われることが多い (可視化のためにGrafanaが一緒に使われる)
- GCPのStackdriverにも対応している
cAdvisor
PrometheusでKubernetes Podの複数ポートに対してScrapeしたいとき
- Scrapeするポートを指定するPodのAnnotation
prometheus.io/port
にはポートを1つしか指定できない- Podの中にScrapeしたいコンテナが複数ある場合に困る
- Prometheus
kubernetes_sd_configs
のrolepod
はAnnotationprometheus.io/port
がない場合、Podのポート全てに対してScrapeする
→つまりAnnotationしないことでPodの複数ポートに対してScrapeさせることができる- 参考: https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml#L247
Scrape the pod on the indicated port instead of the pod's declared ports
- 参考: https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml#L247
- 複数のポートに対してScrapeしたいけど、すべてのポートはちょっと。。。という場合は、ポート名にScrapeするかどうかを識別するsuffixをつけてRelabelで制御するとよい
- 参考: https://github.com/prometheus/prometheus/issues/3756#issuecomment-362266296
- 例
// Drop any endpoint who's pod port name does not end with "-metrics" { source_labels: ['__meta_kubernetes_pod_container_port_name'], action: 'keep', regex: '.*-metrics', },
- ポート名が
-metrics
で終わっていないTargetはDropされる
- ポート名が