【prometheus】-06 Kubernetes云原生监控之cAdvisor容器资源监控

发布时间:2023-12-26 13:15:33

【prometheus】-05 Kubernetes云原生监控之节点性能监控

2021-08-30

【prometheus】-04 轻松搞定Prometheus Eureka服务发现

2021-08-25

【prometheus】-03 轻松搞定Prometheus文件服务发现

2021-08-23

【prometheus】-02 一张图彻底搞懂Prometheus服务发现机制

2021-08-18

【prometheus】- 01 云原生时代的监控系统入门

2021-08-16

Kubernetes监控接入之cAdvisor容器资源监控

概述

Kubernetes 云原生集群监控主要涉及到如下三类指标:node 物理节点指标、pod & container 容器资源指标和Kubernetes 云原生集群资源指标。针对这三类指标都有比较成熟的方案,见下图:

上节我们整理了node性能指标如何监控,这一节我们就来分析下cAdvisor性能指标监控。

cAdvisor(Container Advisor)Google 开源的一个容器监控工具,可用于对容器资源的使用情况和性能进行监控。它以守护进程方式运行,用于收集、聚合、处理和导出正在运行容器的有关信息。具体来说,该组件对每个容器都会记录其资源隔离参数、历史资源使用情况、完整历史资源使用情况的直方图和网络统计信息。cAdvisor 本身就对 Docker 容器支持,并且还对其它类型的容器尽可能的提供支持,力求兼容与适配所有类型的容器。

由以上介绍我们可以知道,cAdvisor 是用于监控容器引擎的,由于其监控的实用性,Kubernetes 已经默认将其与 Kubelet 融合,所以我们无需再单独部署 cAdvisor 组件来暴露节点中容器运行的信息,直接使用 Kubelet 组件提供的指标采集地址即可。

环境信息

本人搭建的 Kubernetes 集群环境如下图,后续都是基于该集群演示:

Prometheus接入

1、访问Prometheus API方式检查:

kubectl?get?--raw?/api/v1/nodes/${1}/proxy/metrics/cadvisor

2、创建Prometheus抓取任务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:
????#?将标签(.*)作为新标签名,原有值不变
????-?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组件抓取指标列表:

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{}

dashboard配置

导入3125 或 13025 dashboardcAdvisor性能监控指标就展示到模板上,如下图:

文章来源:https://blog.csdn.net/god_86/article/details/120052285
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。