diff --git a/checks.d/marathon.py b/checks.d/marathon.py index 0542b4ffa5..f7ec117c7a 100644 --- a/checks.d/marathon.py +++ b/checks.d/marathon.py @@ -1,3 +1,6 @@ +# stdlib +from urlparse import urljoin + # project from checks import AgentCheck @@ -31,7 +34,7 @@ def check(self, instance): default_timeout = self.init_config.get('default_timeout', self.DEFAULT_TIMEOUT) timeout = float(instance.get('timeout', default_timeout)) - response = self.get_json(url + "/v2/apps", timeout) + response = self.get_json(urljoin(url, "/v2/apps"), timeout) if response is not None: self.gauge('marathon.apps', len(response['apps']), tags=instance_tags) for app in response['apps']: @@ -39,7 +42,10 @@ def check(self, instance): for attr in self.APP_METRICS: if attr in app: self.gauge('marathon.' + attr, app[attr], tags=tags) - versions_reply = self.get_json(url + "/v2/apps/" + app['id'] + "/versions", timeout) + + query_url = urljoin(url, "/v2/apps/{0}/versions".format(app['id'])) + versions_reply = self.get_json(query_url, timeout) + if versions_reply is not None: self.gauge('marathon.versions', len(versions_reply['versions']), tags=tags)