From 80538d1af17b71434bc82de4f9088876acf5c562 Mon Sep 17 00:00:00 2001 From: Frederico Marques Date: Thu, 25 Apr 2019 14:35:24 +0100 Subject: [PATCH] BUGFIX: Use job name for instance label when PROMETHEUS_NOLABELS is set to true We were not disabling all labels when PROMETHEUS_NOLABELS is set to true. We now use the job name for the instance label and disabled port label (which is redundant). This way, labels will never change. --- discoverecs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/discoverecs.py b/discoverecs.py index 8c4cd00..67af3eb 100644 --- a/discoverecs.py +++ b/discoverecs.py @@ -285,7 +285,8 @@ def task_info_to_targets(task_info): else: first_port = str(container['networkBindings'][0]['hostPort']) if nolabels: - p_instance = ecs_task_id = ecs_task_version = ecs_container_id = ecs_cluster_name = ec2_instance_id = None + p_instance = ecs_task_name + ecs_task_id = ecs_task_version = ecs_container_id = ecs_cluster_name = ec2_instance_id = None else: p_instance = task_info.ec2_instance['PrivateIpAddress'] + ':' + first_port ecs_task_id=extract_name(task_info.task['taskArn']) @@ -339,9 +340,8 @@ def discover_tasks(self): path_interval = extract_path_interval(target.metrics_path) for path, interval in path_interval.items(): labels = None - if target.p_instance is not None: + if target.ecs_task_name not in target.p_instance: labels = { - 'instance': target.p_instance, 'ecs_task_id' : target.ecs_task_id, 'ecs_task_version' : target.ecs_task_version, 'ecs_container_id' : target.ecs_container_id, @@ -351,8 +351,8 @@ def discover_tasks(self): job = { 'targets' : [target.ip + ':' + target.port], 'labels' : { + 'instance': target.p_instance, 'job' : target.ecs_task_name, - 'port' : target.port, 'metrics_path' : path } }