diff --git a/README.md b/README.md index 991cb38..9af4c7c 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ then `/opt/prometheus-ecs/default-tasks.json` will be written. This can be usefu ### Tags to labels -If `--tags-to-labels` is set, the given tags will be added to the service discovery entry as `tag_` where `` is the given tag formatted to allowed label characters if the tag exists on either the task definition or task. Task tags override the task definition tags. +If `--tags-to-labels` is set, the given tags will be added to the service discovery entry as `__meta_ecs_tag_` where `` is the given tag formatted to allowed label characters if the tag exists on either the task definition or task. Task tags override the task definition tags. If `--tags-to-labels "*"` is provided then _all_ non aws prefixed (`AWS:` or `aws:`) tags will be added. diff --git a/discoverecs.py b/discoverecs.py index 907bf30..88e81be 100644 --- a/discoverecs.py +++ b/discoverecs.py @@ -545,7 +545,7 @@ def discover_tasks(self): # with leading __ reserved for internal use tag_name = re.sub(r"[^a-zA-Z0-9_]", "_", tag_name).lstrip("_") if tag_name != "" and not re.match(r"^[0-9]", tag_name): - job["labels"]["tag_" + tag_name] = tag_value + job["labels"]["__meta_ecs_tag_" + tag_name] = tag_value if labels: job["labels"].update(labels) jobs[interval or self.default_scrape_interval_prefix].append(job)