Merge "Add global_delegeated_tenant field to agent config"
This commit is contained in:
commit
9599bb4912
@ -106,6 +106,13 @@ Main:
|
|||||||
# https://github.com/DataDog/dd-agent/wiki/Network-Traffic-and-Proxy-Configuration
|
# https://github.com/DataDog/dd-agent/wiki/Network-Traffic-and-Proxy-Configuration
|
||||||
# non_local_traffic: no
|
# non_local_traffic: no
|
||||||
|
|
||||||
|
# Submits all metrics to this tenant unless specified by the metric.
|
||||||
|
# This is the equivalent of submitting delegated_tenant with all metrics, and when
|
||||||
|
# not set will submit metrics to the default tenant of the provided credentials.
|
||||||
|
# Used when deploying the agent to systems where the credentials of the monitored
|
||||||
|
# tenant are not known.
|
||||||
|
# global_delegated_tenant:
|
||||||
|
|
||||||
Statsd:
|
Statsd:
|
||||||
# ========================================================================== #
|
# ========================================================================== #
|
||||||
# Monasca Statsd configuration #
|
# Monasca Statsd configuration #
|
||||||
|
@ -35,9 +35,11 @@ class AgentCheck(util.Dimensions):
|
|||||||
self.log = logging.getLogger('%s.%s' % (__name__, name))
|
self.log = logging.getLogger('%s.%s' % (__name__, name))
|
||||||
|
|
||||||
threshold = agent_config.get('recent_point_threshold', None)
|
threshold = agent_config.get('recent_point_threshold', None)
|
||||||
|
tenant_id = agent_config.get('global_delegated_tenant', None)
|
||||||
self.aggregator = (
|
self.aggregator = (
|
||||||
aggregator.MetricsAggregator(self.hostname,
|
aggregator.MetricsAggregator(self.hostname,
|
||||||
recent_point_threshold=threshold))
|
recent_point_threshold=threshold,
|
||||||
|
tenant_id=tenant_id))
|
||||||
|
|
||||||
self.instances = instances or []
|
self.instances = instances or []
|
||||||
self.library_versions = None
|
self.library_versions = None
|
||||||
|
@ -50,10 +50,11 @@ class InvalidValueMeta(Exception):
|
|||||||
class MetricsAggregator(object):
|
class MetricsAggregator(object):
|
||||||
"""A metric aggregator class."""
|
"""A metric aggregator class."""
|
||||||
|
|
||||||
def __init__(self, hostname, recent_point_threshold=None):
|
def __init__(self, hostname, recent_point_threshold=None, tenant_id=None):
|
||||||
self.total_count = 0
|
self.total_count = 0
|
||||||
self.count = 0
|
self.count = 0
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
|
self.global_delegated_tenant = tenant_id
|
||||||
|
|
||||||
recent_point_threshold = recent_point_threshold or RECENT_POINT_THRESHOLD_DEFAULT
|
recent_point_threshold = recent_point_threshold or RECENT_POINT_THRESHOLD_DEFAULT
|
||||||
self.recent_point_threshold = int(recent_point_threshold)
|
self.recent_point_threshold = int(recent_point_threshold)
|
||||||
@ -166,6 +167,8 @@ class MetricsAggregator(object):
|
|||||||
|
|
||||||
hostname_to_post = self.get_hostname_to_post(hostname)
|
hostname_to_post = self.get_hostname_to_post(hostname)
|
||||||
|
|
||||||
|
tenant_to_post = delegated_tenant or self.global_delegated_tenant
|
||||||
|
|
||||||
dimensions_copy = dimensions.copy()
|
dimensions_copy = dimensions.copy()
|
||||||
|
|
||||||
if 'hostname' not in dimensions_copy and hostname_to_post:
|
if 'hostname' not in dimensions_copy and hostname_to_post:
|
||||||
@ -178,13 +181,13 @@ class MetricsAggregator(object):
|
|||||||
|
|
||||||
# TODO(joe): Decide if hostname_to_post and device_name are necessary
|
# TODO(joe): Decide if hostname_to_post and device_name are necessary
|
||||||
# for the context tuple
|
# for the context tuple
|
||||||
context = (name, tuple(dimensions_copy.items()), delegated_tenant,
|
context = (name, tuple(dimensions_copy.items()), tenant_to_post,
|
||||||
hostname_to_post, device_name)
|
hostname_to_post, device_name)
|
||||||
|
|
||||||
if context not in self.metrics:
|
if context not in self.metrics:
|
||||||
self.metrics[context] = metric_class(name,
|
self.metrics[context] = metric_class(name,
|
||||||
dimensions_copy,
|
dimensions_copy,
|
||||||
tenant=delegated_tenant)
|
tenant=tenant_to_post)
|
||||||
cur_time = time()
|
cur_time = time()
|
||||||
if timestamp is not None:
|
if timestamp is not None:
|
||||||
if cur_time - int(timestamp) > self.recent_point_threshold:
|
if cur_time - int(timestamp) > self.recent_point_threshold:
|
||||||
|
@ -36,7 +36,8 @@ class MonascaStatsd(object):
|
|||||||
|
|
||||||
# Create the aggregator (which is the point of communication between the server and reporting threads.
|
# Create the aggregator (which is the point of communication between the server and reporting threads.
|
||||||
aggregator = agg.MetricsAggregator(util.get_hostname(),
|
aggregator = agg.MetricsAggregator(util.get_hostname(),
|
||||||
recent_point_threshold=statsd_config['recent_point_threshold'])
|
recent_point_threshold=statsd_config['recent_point_threshold'],
|
||||||
|
tenant_id=statsd_config.get('global_delegated_tenant', None))
|
||||||
|
|
||||||
# Start the reporting thread.
|
# Start the reporting thread.
|
||||||
interval = int(statsd_config['monasca_statsd_interval'])
|
interval = int(statsd_config['monasca_statsd_interval'])
|
||||||
|
Loading…
Reference in New Issue
Block a user