Skip to content

Commit

Permalink
BUGFIX: Use job name for instance label when PROMETHEUS_NOLABELS is s…
Browse files Browse the repository at this point in the history
…et 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.
  • Loading branch information
fredsig committed Apr 25, 2019
1 parent e4935c1 commit 80538d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions discoverecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
}
Expand Down

0 comments on commit 80538d1

Please sign in to comment.