From 138b88e8e9c1e987258c953b03a55b7168cc06be Mon Sep 17 00:00:00 2001 From: Yann Mahe Date: Mon, 3 Aug 2015 11:37:28 -0400 Subject: [PATCH] [network] normalize instance_name tags Instance name used to be a part of the check name and hence normalized on the agent before being sent to Datadog. As part of changes #1642 which introduced support for custom tags, 'instance_name' is now sent as a proper tag. Normalize it, to avoid mismatch and backward incompatiblity. Fix #1796. --- checks.d/http_check.py | 3 +-- checks.d/tcp_check.py | 2 +- checks/__init__.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/checks.d/http_check.py b/checks.d/http_check.py index 4a35e48650..bca6ee5a49 100644 --- a/checks.d/http_check.py +++ b/checks.d/http_check.py @@ -72,7 +72,6 @@ def _check(self, instance): start = time.time() service_checks = [] - try: self.log.debug("Connecting to %s" % addr) if disable_ssl_validation and urlparse(addr)[0] == "https": @@ -240,7 +239,7 @@ def _create_status_event(self, sc_name, status, msg, instance): } def report_as_service_check(self, sc_name, status, instance, msg=None): - instance_name = instance['name'] + instance_name = self.normalize(instance['name']) url = instance.get('url', None) sc_tags = ['url:{0}'.format(url), "instance:{0}".format(instance_name)] custom_tags = instance.get('tags', []) diff --git a/checks.d/tcp_check.py b/checks.d/tcp_check.py index 47d8c5549a..dc91535640 100644 --- a/checks.d/tcp_check.py +++ b/checks.d/tcp_check.py @@ -152,7 +152,7 @@ def _create_status_event(self, sc_name, status, msg, instance): } def report_as_service_check(self, sc_name, status, instance, msg=None): - instance_name = instance['name'] + instance_name = self.normalize(instance['name']) host = instance.get('host', None) port = instance.get('port', None) custom_tags = instance.get('tags', []) diff --git a/checks/__init__.py b/checks/__init__.py index 5a9c5c02ed..d78c353dec 100644 --- a/checks/__init__.py +++ b/checks/__init__.py @@ -744,7 +744,7 @@ def from_yaml(cls, path_to_yaml=None, agentConfig=None, yaml_text=None, check_na check = cls(check_name, config.get('init_config') or {}, agentConfig or {}) return check, config.get('instances', []) - def normalize(self, metric, prefix=None, fix_case = False): + def normalize(self, metric, prefix=None, fix_case=False): """ Turn a metric into a well-formed metric name prefix.b.c