Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/diamond/handler/cloudwatch.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,6 +36,9 @@
name = Avg05
namespace = MachineLoad
unit = None
[[[[dimensions]]]]
environment = dev

"""

import sys
Expand DownExpand Up@@ -87,7 +90,7 @@ def __init__(self, config=None):

self.valid_config = ('region', 'collector', 'metric', 'namespace',
'name', 'unit', 'collect_by_instance',
'collect_without_dimension')
'collect_without_dimension', 'dimensions')

self.rules = []
for key_name, section in self.config.items():
Expand DownExpand Up@@ -118,7 +121,8 @@ def get_default_rule_config(self):
'name': '',
'unit': 'None',
'collect_by_instance': True,
'collect_without_dimension': False
'collect_without_dimension': False,
'dimensions': {}
})
return config

Expand All@@ -136,7 +140,8 @@ def get_default_config_help(self):
'unit': 'CloudWatch metric unit',
'collector': 'Diamond collector name',
'collect_by_instance': 'Collect metrics for instances separately',
'collect_without_dimension': 'Collect metrics without dimension'
'collect_without_dimension': 'Collect metrics without dimension',
'dimensions': 'Additional dimensions to pass (Up to 10)'
})

return config
Expand DownExpand Up@@ -212,10 +217,12 @@ def process(self, metric):
str(rule['metric']) == metricname)):

if rule['collect_by_instance'] and self.instance_id:
dimensions = rule['dimensions']
dimensions['InstanceId'] = self.instance_id
self.send_metrics_to_cloudwatch(
rule,
metric,
{'InstanceId': self.instance_id})
dimensions)

if rule['collect_without_dimension']:
self.send_metrics_to_cloudwatch(
Expand Down