Skip to content

Commit

Permalink
Only Normalize Task CPU limits
Browse files Browse the repository at this point in the history
Container limits are always in CPU shares, while task limits are in
vCpus
  • Loading branch information
raags committed Jun 28, 2021
1 parent f70b809 commit 36364e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ecs_container_exporter/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.2.0'
__version__ = '2.3.0'
6 changes: 3 additions & 3 deletions ecs_container_exporter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def parse_task_metadata(self, metadata):

# task cpu/mem limit
task_tag = utils.task_metric_tags()
self.task_cpu_limit, self.task_mem_limit = self.cpu_mem_limit(metadata)
self.task_cpu_limit, self.task_mem_limit = self.cpu_mem_limit(metadata, normalise_cpu=True)

metric = create_metric('cpu_limit', self.task_cpu_limit, task_tag, 'gauge', 'Task CPU limit')
self.static_task_metrics.append(metric)
Expand Down Expand Up @@ -177,9 +177,9 @@ def should_process_container(self, container_name, include_containers, exclude_c
else:
return True

def cpu_mem_limit(self, metadata):
def cpu_mem_limit(self, metadata, normalise_cpu=False):
# normalise to `cpu shares`
cpu_limit = metadata.get('Limits', {}).get('CPU', 0) * 1024
cpu_limit = metadata.get('Limits', {}).get('CPU', 0) * (1024 if normalise_cpu else 1)
mem_limit = metadata.get('Limits', {}).get('Memory', 0)

return (
Expand Down

0 comments on commit 36364e8

Please sign in to comment.