feat: cadvisor - options to enable\disable metrics and docker-only mode

Signed-off-by: Oleg Klyuchkin <anviar@users.noreply.github.com>
This commit is contained in:
Oleg Klyuchkin 2024-03-06 21:19:28 +03:00
parent b84a1f4a2c
commit 92cfd70d49
No known key found for this signature in database
GPG key ID: 1D9496B16B0FC606
3 changed files with 49 additions and 0 deletions

View file

@ -9,6 +9,10 @@ cadvisor_listen_ip: "0.0.0.0"
cadvisor_port: "8080"
cadvisor_prometheus_endpoint: "/metrics"
cadvisor_enable_metrics: []
cadvisor_disable_metrics: []
cadvisor_docker_only: false
cadvisor_binary_install_dir: "/usr/local/bin"
cadvisor_system_group: "root"
cadvisor_system_user: "{{ cadvisor_system_group }}"

View file

@ -32,6 +32,42 @@ argument_specs:
cadvisor_prometheus_endpoint:
description: "Path under which to expose metrics"
default: "/metrics"
cadvisor_disable_metrics:
description:
- "comma-separated list of metrics to be disabled"
- "(default advtcp,cpu_topology,cpuset,hugetlb,memory_numa,process,referenced_memory,resctrl,sched,tcp,udp)"
type: "list"
default: []
choices: &metrics_choices
- advtcp
- app
- cpu
- cpuLoad
- cpu_topology
- cpuset
- disk
- diskIO
- hugetlb
- memory
- memory_numa
- network
- oom_event
- percpu
- perf_event
- process
- referenced_memory
- resctrl
- sched
- tcp
cadvisor_enable_metrics:
description: "comma-separated list of metrics to be enabled. If set, overrides 'cadvisor_disable_metrics'"
default: []
type: "list"
choices: *metrics_choices
cadvisor_docker_only:
description: "do not report raw cgroup metrics, except the root cgroup"
type: "bool"
default: false
cadvisor_binary_install_dir:
description:
- "I(Advanced)"

View file

@ -9,6 +9,15 @@ Type=simple
User={{ cadvisor_system_user }}
Group={{ cadvisor_system_group }}
ExecStart={{ cadvisor_binary_install_dir }}/cadvisor \
{% if cadvisor_disable_metrics | length > 0 %}
'--disable_metrics={{ cadvisor_disable_metrics | join(',') }}' \
{% endif -%}
{% if cadvisor_enable_metrics | length > 0 %}
'--enable_metrics={{ cadvisor_enable_metrics | join(',') }}' \
{% endif -%}
{% if cadvisor_docker_only %}
'--docker_only={{ cadvisor_docker_only | lower }}' \
{% endif -%}
'--listen_ip={{ cadvisor_listen_ip }}' \
'--port={{ cadvisor_port }}' \
'--prometheus_endpoint={{ cadvisor_prometheus_endpoint }}'