你确定标签__meta_container_label_com_amazonaws_ecs_cluster
存在吗?我在 AWS ECS 集群中运行 Cadvisor,并从 container_label_com_amazonaws_ecs_container_name
. 它不是元标签,而是由 Cadvisor 从 Docker 标签中提取的。
__meta.+
标签由 检索relabel_configs
。这是我配置的那部分的样子:
- job_name: cadvisor
ec2_sd_configs:
- region: eu-central-1
port: 28080
filters:
- name: tag:aws:autoscaling:groupName
values:
- data-dev
- data-prod
relabel_configs:
- action: replace
source_labels: [__meta_ec2_instance_id]
target_label: instance_id
- action: replace
source_labels: [__meta_ec2_instance_state]
target_label: instance_state
- action: replace
source_labels: [__meta_ec2_instance_type]
target_label: instance_type
metric_relabel_configs:
# Drop series.
- action: drop
source_labels: [__name__]
regex: "(container_tasks_state|container_cpu_load_average_10s)"
# Drop all series that do not have a 'name' label.
- action: keep
source_labels: [name]
regex: (.+)
# Drop all series that do not have a '/ecs/' c group prefix and a proper
# container id after the third forword slash.
- action: keep
source_labels: [id]
regex: ^/ecs/.+/.+
# Drop label 'instance_type'.
- action: labeldrop
regex: instance_type
# Rewrite 'id' label to only include short form container id.
- action: replace
source_labels: [id]
target_label: id
regex: ^/ecs/.+/(.{0,12}).*
replacement: $1
# Rename label task family.
- action: replace
source_labels: [container_label_com_amazonaws_ecs_task_definition_family]
target_label: task_family
- action: labeldrop
regex: container_label_com_amazonaws_ecs_task_definition_family
# Overwrite 'name' with value of container name label.
- action: replace
source_labels: [container_label_com_amazonaws_ecs_container_name]
target_label: name
- action: labeldrop
regex: container_label_com_amazonaws_ecs_container_name
# namespace
- action: replace
source_labels: [container_label_promstack_namespace]
target_label: namespace
- action: labeldrop
regex: container_label_promstack_namespace
# api_type
- action: replace
source_labels: [container_label_promstack_api_type]
target_label: api_type
- action: labeldrop
regex: container_label_promstack_api_type