cAdvisor Exporter

配置并启用cadvisor_exporter

在docker中启动 grafana-agent,同时映射相关目录

  1. -v /tmp/agent:/etc/agent/data \
  2. -v /tmp/grafana-agent-cfg.yaml:/etc/agent/agent.yaml \
  3. -p 12345:12345 \
  4. -d \
  5. --privileged \
  6. grafana/agent:v0.23.0 \
  7. --config.file=/etc/agent/agent.yaml \
  8. --metrics.wal-directory=/etc/agent/data
  1. cadvisor_version_info{cadvisorRevision="",cadvisorVersion="",dockerVersion="",kernelVersion="5.10.76-linuxkit",osVersion="Debian GNU/Linux 10 (buster)"} 1
  2. container_blkio_device_usage_total{device="/dev/vda",id="/",major="254",minor="0",operation="Read"} 4.6509056e+07 1645109878135
  3. container_blkio_device_usage_total{device="/dev/vda",id="/",major="254",minor="0",operation="Write"} 3.13243648e+09 1645109878135
  4. container_cpu_load_average_10s{id="/"} 0 1645109878135
  5. container_cpu_system_seconds_total{id="/"} 57.789 1645109878135
  6. container_cpu_usage_seconds_total{cpu="total",id="/"} 91.57 1645109878135
  7. container_cpu_user_seconds_total{id="/"} 33.781 1645109878135
  8. container_fs_inodes_free{device="/dev",id="/"} 254415 1645109878135
  9. container_fs_inodes_free{device="/dev/shm",id="/"} 254551 1645109878135
  10. container_fs_inodes_free{device="/dev/vda1",id="/"} 3.890602e+06 1645109878135
  11. container_fs_inodes_free{device="/rootfs/dev/shm",id="/"} 254551 1645109878135
  12. ...

采集的指标列表

完整地配置项说明

  1. # Enables the cadvisor integration, allowing the Agent to automatically
  2. # collect metrics for the specified github objects.
  3. [enabled: <boolean> | default = false]
  4. # Sets an explicit value for the instance label when the integration is
  5. # self-scraped. Overrides inferred values.
  6. [instance: <string> | default = <integrations_config.instance>]
  7. # Automatically collect metrics from this integration. If disabled,
  8. # the cadvisor integration will be run but not scraped and thus not
  9. # remote-written. Metrics for the integration will be exposed at
  10. # /integrations/cadvisor/metrics and can be scraped by an external
  11. # process.
  12. [scrape_integration: <boolean> | default = <integrations_config.scrape_integrations>]
  13. # How often should the metrics be collected? Defaults to
  14. [scrape_interval: <duration> | default = <global_config.scrape_interval>]
  15. # The timeout before considering the scrape a failure. Defaults to
  16. # prometheus.global.scrape_timeout.
  17. [scrape_timeout: <duration> | default = <global_config.scrape_timeout>]
  18. # Allows for relabeling labels on the target.
  19. relabel_configs:
  20. [- <relabel_config> ... ]
  21. # Relabel metrics coming from the integration, allowing to drop series
  22. # from the integration that you don't care about.
  23. metric_relabel_configs:
  24. [ - <relabel_config> ... ]
  25. # How frequent to truncate the WAL for this integration.
  26. [wal_truncate_frequency: <duration> | default = "60m"]
  27. #
  28. # cAdvisor-specific configuration options
  29. #
  30. # Convert container labels and environment variables into labels on prometheus metrics for each container. If false, then only metrics exported are container name, first alias, and image name.
  31. [store_container_labels: <boolean> | default = true]
  32. # List of container labels to be converted to labels on prometheus metrics for each container. store_container_labels must be set to false for this to take effect.
  33. allowlisted_container_labels:
  34. [ - <string> ]
  35. # List of environment variable keys matched with specified prefix that needs to be collected for containers, only support containerd and docker runtime for now.
  36. env_metadata_allowlist:
  37. [ - <string> ]
  38. # List of cgroup path prefix that needs to be collected even when docker_only is specified.
  39. raw_cgroup_prefix_allowlist:
  40. [ - <string> ]
  41. # resctrl mon groups updating interval. Zero value disables updating mon groups.
  42. [resctrl_interval: <int> | default = 0]
  43. # List of `metrics` to be disabled. If set, overrides the default disabled metrics.
  44. disabled_metrics:
  45. [ - <string> ]
  46. # List of `metrics` to be enabled. If set, overrides disabled_metrics
  47. enabled_metrics:
  48. [ - <string> ]
  49. # Length of time to keep data stored in memory
  50. [storage_duration: <duration> | default = "2m"]
  51. # Containerd endpoint
  52. [containerd: <string> | default = "/run/containerd/containerd.sock"]
  53. # Containerd namespace
  54. [containerd_namespace: <string> | default = "k8s.io"]
  55. # Docker endpoint
  56. [docker: <string> | default = "unix:///var/run/docker.sock"]
  57. # Use TLS to connect to docker
  58. [docker_tls: <boolean> | default = false]
  59. # Path to client certificate for TLS connection to docker
  60. [docker_tls_cert: <string> | default = "cert.pem"]
  61. # Path to private key for TLS connection to docker
  62. [docker_tls_key: <string> | default = "key.pem"]
  63. # Path to a trusted CA for TLS connection to docker
  64. [docker_tls_ca: <string> | default = "ca.pem"]
  65. # Only report docker containers in addition to root stats
  66. [docker_only: <boolean> | default = false]