Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distinguish each value_list.host and pass through to cloudwatch dimension #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/cloudwatch/config/plugin.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# The host parameter can be used to override instance-id or host information published with every metric
#host = "Server1"

#pass_vl_host = "False"

# The pass through option allows unsafe regexes such as '.*' or '.+'.
# WARNING: ENABLING THIS OPTION MAY LEAD TO PUBLISHING A LARGE NUMBER OF METRICS
# SEE https://aws.amazon.com/cloudwatch/pricing/ TO UNDERSTAND HOW TO ESTIMATE YOUR BILL.
Expand Down
2 changes: 2 additions & 0 deletions src/cloudwatch/modules/configuration/confighelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, config_path=_DEFAULT_CONFIG_PATH, metadata_server=_METADATA_S
self.endpoint = ''
self.ec2_endpoint = ''
self.host = ''
self.pass_vl_host = False
self.asg_name = 'NONE'
self.proxy_server_name = ''
self.proxy_server_port = ''
Expand Down Expand Up @@ -89,6 +90,7 @@ def _load_configuration(self):
self.push_asg = self.config_reader.push_asg
self.push_constant = self.config_reader.push_constant
self.constant_dimension_value = self.config_reader.constant_dimension_value
self.pass_vl_host = self.config_reader.pass_vl_host
self._check_configuration_integrity()

def _get_credentials_path(self):
Expand Down
5 changes: 5 additions & 0 deletions src/cloudwatch/modules/configuration/configreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ConfigReader(object):
credentials_path -- the path to the file with AWS access and secret keys
region -- the region in which host operates
host -- the host name or instance name injected to each metric as dimension
pass_vl_host -- use host in value_list in dimension
debug -- the mode in which plugin performs verbose logging of its operations
pass_through -- the mode in which whitelist allows use of .* on its own

Expand All @@ -24,11 +25,13 @@ class ConfigReader(object):
_LOGGER = get_logger(__name__)
_DEBUG_DEFAULT_VALUE = False
_ENABLE_HIGH_DEFINITION_METRICS_DEFAULT_VALUE = False
_PASS_VL_HOST_DEFAULT_VALUE = False
_PASS_THROUGH_DEFAULT_VALUE = False
_PUSH_ASG_DEFAULT_VALUE = False
_PUSH_CONSTANT_DEFAULT_VALUE = False
REGION_CONFIG_KEY = "region"
HOST_CONFIG_KEY = "host"
PASS_VL_HOST_CONFIG_KEY = "pass_vl_host"
CREDENTIALS_PATH_KEY = "credentials_path"
DEBUG_CONFIG_KEY = "debug"
PASS_THROUGH_CONFIG_KEY = "whitelist_pass_through"
Expand All @@ -45,6 +48,7 @@ def __init__(self, config_path):
self.credentials_path = ""
self.region = ''
self.host = ''
self.pass_vl_host = self._PASS_VL_HOST_DEFAULT_VALUE
self.pass_through = self._PASS_THROUGH_DEFAULT_VALUE
self.debug = self._DEBUG_DEFAULT_VALUE
self.push_asg = self._PUSH_ASG_DEFAULT_VALUE
Expand All @@ -68,6 +72,7 @@ def _parse_config_file(self):
"""
self.credentials_path = self.reader_utils.get_string(self.CREDENTIALS_PATH_KEY)
self.host = self.reader_utils.get_string(self.HOST_CONFIG_KEY)
self.pass_vl_host = self.reader_utils.try_get_boolean(self.PASS_VL_HOST_CONFIG_KEY, self._PASS_VL_HOST_DEFAULT_VALUE)
self.region = self.reader_utils.get_string(self.REGION_CONFIG_KEY)
self.proxy_server_name = self.reader_utils.get_string(self.PROXY_SERVER_NAME_KEY)
self.proxy_server_port = self.reader_utils.get_string(self.PROXY_SERVER_PORT_KEY)
Expand Down
2 changes: 2 additions & 0 deletions src/cloudwatch/modules/flusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def _aggregate_metric(self, value_list):
key = dimension_key
if self.enable_high_resolution_metrics:
key = dimension_key + "-" + str(adjusted_time)
if self.config.pass_vl_host:
key = value_list.host + '/' + key
if key in self.metric_map:
nan_value_count = self._add_values_to_metrics(self.metric_map[key], value_list)
else:
Expand Down
2 changes: 2 additions & 0 deletions src/cloudwatch/modules/metricdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def _get_plugin_instance_dimension(self):
return "NONE"

def _get_host_dimension(self):
if self.config.pass_vl_host:
return self.vl.host
if self.config.host:
return self.config.host
return self.vl.host
Expand Down