search
数据采集 采集源配置 Docker 指标采集

Docker 指标采集

简介

采集 docker 指标上报到 DataFlux 中

场景参考

Docker Overview视图

内置视图

内置视图

内置视图

Docker container内置视图

内置视图

内置视图

Docker视图模板下载

前置条件

配置

进入 DataKit 安装目录下的 conf.d/docker 目录,复制 docker.conf.sample 并命名为 docker.conf。示例如下:

  • docker.conf.sample:docker采集器会同时采集docker服务的基本状态以及container容器信息两个部分。
  • docker_containers.conf.sample:docker容器对象采集器,详见(Docker 容器对象采集

设置:

# Read metrics about docker containers
[[inputs.docker]]
  ## Docker Endpoint
  ##   To use TCP, set endpoint = "tcp://[ip]:[port]"
  ##   To use environment variables (ie, docker-machine), set endpoint = "ENV"
  endpoint = "unix:///var/run/docker.sock"

  ## Set to true to collect Swarm metrics(desired_replicas, running_replicas)
  ## Note: configure this in one of the manager nodes in a Swarm cluster.
  ## configuring in multiple Swarm managers results in duplication of metrics.
  gather_services = false

  ## Only collect metrics for these containers. Values will be appended to
  ## container_name_include.
  ## Deprecated (1.4.0), use container_name_include
  container_names = []

  ## Set the source tag for the metrics to the container ID hostname, eg first 12 chars
  source_tag = false

  ## Containers to include and exclude. Collect all if empty. Globs accepted.
  container_name_include = []
  container_name_exclude = []

  ## Container states to include and exclude. Globs accepted.
  ## When empty only containers in the "running" state will be captured.
  ## example: container_state_include = ["created", "restarting", "running", "removing", "paused", "exited", "dead"]
  ## example: container_state_exclude = ["created", "restarting", "running", "removing", "paused", "exited", "dead"]
  # container_state_include = []
  # container_state_exclude = []

  ## Timeout for docker list, info, and stats commands
  timeout = "5s"

  ## Whether to report for each container per-device blkio (8:0, 8:1...) and
  ## network (eth0, eth1, ...) stats or not
  perdevice = true

  ## Whether to report for each container total blkio and network stats or not
  total = false

  ## docker labels to include and exclude as tags.  Globs accepted.
  ## Note that an empty array for both will include all labels as tags
  docker_label_include = []
  docker_label_exclude = []

  ## Which environment variables should we use as a tag
  tag_env = ["JAVA_HOME", "HEAP_SIZE"]

  ## Optional TLS Config
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

配置好后,重启 DataKit 即可生效

采集指标

docker 指标

指标 描述 类型 单位 Tag
n_used_file_descriptors integer - unit,engine_host,server_version
n_cpus 容器可运行的CPU内核数 integer - unit,engine_host,server_version
n_containers 容器数量 integer - unit,engine_host,server_version
n_containers_running 运行的容器数量 integer - unit,engine_host,server_version
n_containers_stopped 停止的容器数量 integer - unit,engine_host,server_version
n_containers_paused 暂停的容器数量 integer - unit,engine_host,server_version
n_images 镜像数量 integer - unit,engine_host,server_version
n_listener_events 事件监听数 integer - unit,engine_host,server_version
n_goroutines go并发线程数 integer - unit,engine_host,server_version
memory_total 内存总计 integer - unit,engine_host,server_version

docker_swam 指标

指标 描述 类型 单位 Tag
tasks_desired - service_id,service_name,service_mode
tasks_running - service_id,service_name,service_mode

docker_container_cpu 指标

指标 描述 类型 单位 Tag
throttling_periods - engine_host,server_version,container_image,container_name,container_status,container_version,cpu
throttling_throttled_periods - engine_host,server_version,container_image,container_name,container_status,container_version,cpu
throttling_throttled_time - engine_host,server_version,container_image,container_name,container_status,container_version,cpu
usage_in_kernelmode 内核模式资源使用 - engine_host,server_version,container_image,container_name,container_status,container_version,cpu
usage_in_usermode 用户模式资源使用 - engine_host,server_version,container_image,container_name,container_status,container_version,cpu
usage_system 系统资源使用 - engine_host,server_version,container_image,container_name,container_status,container_version,cpu
usage_total 使用资源总计 - engine_host,server_version,container_image,container_name,container_status,container_version,cpu
cpu_usage CPU使用率 - engine_host,server_version,container_image,container_name,container_status,container_version,cpu
container_id 容器ID - engine_host,server_version,container_image,container_name,container_status,container_version,cpu

docker_container_mem 指标

指标 描述 类型 单位 Tag
total_pgmajfault - engine_host,server_version,container_image,container_name,container_status,container_version
cache - engine_host,server_version,container_image,container_name,container_status,container_version
mapped_file - engine_host,server_version,container_image,container_name,container_status,container_version
total_mapped_file - engine_host,server_version,container_image,container_name,container_status,container_version
pgpgout - engine_host,server_version,container_image,container_name,container_status,container_version
rss - engine_host,server_version,container_image,container_name,container_status,container_version
total_mapped_file - engine_host,server_version,container_image,container_name,container_status,container_version
writeback - engine_host,server_version,container_image,container_name,container_status,container_version
unevictable - engine_host,server_version,container_image,container_name,container_status,container_version
pgpgin - engine_host,server_version,container_image,container_name,container_status,container_version
total_unevictable - engine_host,server_version,container_image,container_name,container_status,container_version
pgmajfault - engine_host,server_version,container_image,container_name,container_status,container_version
total_rss - engine_host,server_version,container_image,container_name,container_status,container_version
total_rss_huge - engine_host,server_version,container_image,container_name,container_status,container_version
total_writeback - engine_host,server_version,container_image,container_name,container_status,container_version
total_inactive_anon - engine_host,server_version,container_image,container_name,container_status,container_version
rss_huge - engine_host,server_version,container_image,container_name,container_status,container_version
hierarchical_memory_limit - engine_host,server_version,container_image,container_name,container_status,container_version
total_pgfault - engine_host,server_version,container_image,container_name,container_status,container_version
total_active_file - engine_host,server_version,container_image,container_name,container_status,container_version
active_anon - engine_host,server_version,container_image,container_name,container_status,container_version
total_active_anon - engine_host,server_version,container_image,container_name,container_status,container_version
total_pgpgout - engine_host,server_version,container_image,container_name,container_status,container_version
total_cache - engine_host,server_version,container_image,container_name,container_status,container_version
inactive_anon - engine_host,server_version,container_image,container_name,container_status,container_version
active_file - engine_host,server_version,container_image,container_name,container_status,container_version
pgfault - engine_host,server_version,container_image,container_name,container_status,container_version
inactive_file - engine_host,server_version,container_image,container_name,container_status,container_version
total_pgpgin - engine_host,server_version,container_image,container_name,container_status,container_version
max_usage - engine_host,server_version,container_image,container_name,container_status,container_version
usage - engine_host,server_version,container_image,container_name,container_status,container_version
failcnt - engine_host,server_version,container_image,container_name,container_status,container_version
limit - engine_host,server_version,container_image,container_name,container_status,container_version
container_id - engine_host,server_version,container_image,container_name,container_status,container_version

docker_container_net 指标

指标 描述 类型 单位 Tag
rx_dropped 丢弃的接收包 - engine_host,server_version,container_image,container_name,container_status,container_version,network
rx_bytes 接收的字节数 - engine_host,server_version,container_image,container_name,container_status,container_version,network
rx_errors 接收的错误数 - engine_host,server_version,container_image,container_name,container_status,container_version,network
tx_packets 发送的数据包 - engine_host,server_version,container_image,container_name,container_status,container_version,network
tx_dropped 丢弃的发送包 - engine_host,server_version,container_image,container_name,container_status,container_version,network
rx_packets 接收的数据包 - engine_host,server_version,container_image,container_name,container_status,container_version,network
tx_errors 发送的错误数 - engine_host,server_version,container_image,container_name,container_status,container_version,network
tx_bytes 发送的字节数 - engine_host,server_version,container_image,container_name,container_status,container_version,network
container_id 容器ID - engine_host,server_version,container_image,container_name,container_status,container_version,network

docker_container_blkio 指标

指标 描述 类型 单位 Tag
io_service_bytes_recursive_async 容器卷的异步块I/O请求字节数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
io_service_bytes_recursive_read 容器卷的块读取字节数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
io_service_bytes_recursive_sync 容器卷的同步块I/O请求字节数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
io_service_bytes_recursive_total 容器卷的块读写字节总数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
io_service_bytes_recursive_write 容器卷的块写入字节数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
io_serviced_recursive_async 已服务异步块I/O请求数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
io_serviced_recursive_read 已服务块设备的读取请求数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
io_serviced_recursive_sync 已服务的同步块I/O请求数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
io_serviced_recursive_total 已服务的块读写请求总数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
io_serviced_recursive_write 已服务块设备的写入请求计数 - engine_host,server_version,container_image,container_name,container_status,container_version,device
container_id 容器ID - engine_host,server_version,container_image,container_name,container_status,container_version,device

docker_container_health 指标 (容器必须开启 HEALTHCHECK)

指标 描述 类型 单位 Tag
health_status string - engine_host,server_version,container_image,container_name,container_status,container_version
failing_streak integer - engine_host,server_version,container_image,container_name,container_status,container_version

docker_container_status 指标

指标 描述 类型 单位 Tag
container_id 容器ID - engine_host,server_version,container_image,container_name,container_status,container_version
oomkilled 内存用尽kill boolean - engine_host,server_version,container_image,container_name,container_status,container_version
pid 进程ID integer - engine_host,server_version,container_image,container_name,container_status,container_version
exitcode 退出代码 integer - engine_host,server_version,container_image,container_name,container_status,container_version
started_at 容器开始时间 integer - engine_host,server_version,container_image,container_name,container_status,container_version
finished_at 容器结束时间 integer - engine_host,server_version,container_image,container_name,container_status,container_version
uptime_ns 容器运行时间 integer - engine_host,server_version,container_image,container_name,container_status,container_version

docker_devicemapper

指标 描述 类型 单位 Tag
pool_blocksize_bytes 存储池块大小 - engine_host,server_version,pool_name
data_space_used_bytes 数据空间的使用字节数 - engine_host,server_version,pool_name
data_space_total_bytes 数据空间的总字节数 - engine_host,server_version,pool_name
data_space_available_bytes 数据空间的可用字节数 - engine_host,server_version,pool_name
metadata_space_used_bytes 元数据空间的使用字节数 - engine_host,server_version,pool_name
metadata_space_total_bytes 元数据空间的总字节数 - engine_host,server_version,pool_name
metadata_space_available_bytes 元数据空间的可用字节数 - engine_host,server_version,pool_name
thin_pool_minimum_free_space_bytes 精简存储池的最小可用空间字节数 - engine_host,server_version,pool_name