(資料圖片僅供參考)
Kubernetes
云原生集群監(jiān)控主要涉及到如下三類指標(biāo):node
物理節(jié)點(diǎn)指標(biāo)、pod & container
容器資源指標(biāo)和Kubernetes
云原生集群資源指標(biāo)。針對(duì)這三類指標(biāo)都有比較成熟的方案,見下圖:
上節(jié)我們整理了node
性能指標(biāo)如何監(jiān)控,這一節(jié)我們就來(lái)分析下cAdvisor
性能指標(biāo)監(jiān)控。
cAdvisor(Container Advisor)
是 Google
開源的一個(gè)容器監(jiān)控工具,可用于對(duì)容器資源的使用情況和性能進(jìn)行監(jiān)控。它以守護(hù)進(jìn)程方式運(yùn)行,用于收集、聚合、處理和導(dǎo)出正在運(yùn)行容器的有關(guān)信息。具體來(lái)說(shuō),該組件對(duì)每個(gè)容器都會(huì)記錄其資源隔離參數(shù)、歷史資源使用情況、完整歷史資源使用情況的直方圖和網(wǎng)絡(luò)統(tǒng)計(jì)信息。cAdvisor
本身就對(duì) Docker
容器支持,并且還對(duì)其它類型的容器盡可能的提供支持,力求兼容與適配所有類型的容器。
由以上介紹我們可以知道,cAdvisor
是用于監(jiān)控容器引擎的,由于其監(jiān)控的實(shí)用性,Kubernetes
已經(jīng)默認(rèn)將其與 Kubelet
融合,所以我們無(wú)需再單獨(dú)部署 cAdvisor
組件來(lái)暴露節(jié)點(diǎn)中容器運(yùn)行的信息,直接使用 Kubelet
組件提供的指標(biāo)采集地址即可。
本人搭建的 Kubernetes
集群環(huán)境如下圖,后續(xù)都是基于該集群演示:
1、訪問Prometheus API
方式檢查:
kubectl get --raw /api/v1/nodes/${1}/proxy/metrics/cadvisor
2、創(chuàng)建Prometheus
抓取任務(wù)job
:
- job_name: kubernetes-nodes-cadvisor metrics_path: /metrics scheme: https kubernetes_sd_configs: - role: node api_server: https://apiserver.simon:6443 bearer_token_file: /tools/token.k8s tls_config: insecure_skip_verify: true bearer_token_file: /tools/token.k8s tls_config: insecure_skip_verify: true relabel_configs: # 將標(biāo)簽(.*)作為新標(biāo)簽名,原有值不變 - action: labelmap regex: __meta_kubernetes_node_label_(.*) # 修改NodeIP:10250為APIServerIP:6443 - action: replace regex: (.*) source_labels: ["__address__"] target_label: __address__ replacement: 192.168.52.151:6443 #apiserver - action: replace source_labels: [__meta_kubernetes_node_name] target_label: __metrics_path__ regex: (.*) replacement: /api/v1/nodes/${1}/proxy/metrics/cadvisor
3、檢查是否接入成功:
4、cAdvisor
組件抓取指標(biāo)列表:
container_fs_write_seconds_total{}container_memory_swap{}container_spec_cpu_shares{}container_ulimits_soft{}container_fs_io_current{}container_fs_reads_bytes_total{}container_fs_writes_merged_total{}container_cpu_user_seconds_total{}container_memory_failcnt{}container_memory_failures_total{}container_cpu_cfs_throttled_seconds_total{}container_cpu_usage_seconds_total{}container_fs_io_time_seconds_total{}container_network_receive_packets_total{}container_spec_memory_reservation_limit_bytes{}cadvisor_version_info{}container_cpu_cfs_periods_total{}container_fs_limit_bytes{}container_fs_sector_writes_total{}container_memory_usage_bytes{}container_memory_working_set_bytes{}container_network_receive_errors_total{}container_network_transmit_packets_dropped_total{}container_spec_cpu_period{}container_file_descriptors{}container_fs_inodes_total{}container_fs_usage_bytes{}container_network_transmit_packets_total{}container_cpu_load_average_10s{}container_fs_writes_bytes_total{}container_memory_cache{}container_spec_cpu_quota{}container_cpu_cfs_throttled_periods_total{}container_network_receive_bytes_total{}container_network_transmit_errors_total{}container_sockets{}container_spec_memory_swap_limit_bytes{}container_threads{}container_threads_max{}container_cpu_system_seconds_total{}container_fs_read_seconds_total{}container_fs_reads_merged_total{}container_fs_sector_reads_total{}container_processes{}container_spec_memory_limit_bytes{}container_fs_inodes_free{}container_network_receive_packets_dropped_total{}container_network_transmit_bytes_total{}container_fs_io_time_weighted_seconds_total{}container_fs_reads_total{}container_fs_writes_total{}container_memory_max_usage_bytes{}container_memory_rss{}container_scrape_error{}container_start_time_seconds{}container_last_seen{}container_memory_mapped_file{}container_tasks_state{}
導(dǎo)入3125 或 13025 dashboard
,cAdvisor
性能監(jiān)控指標(biāo)就展示到模板上,如下圖:
關(guān)鍵詞: