Skip to content

Commit

Permalink
Merge pull request #1401 from DataDog/remh/fix_marathon_url
Browse files Browse the repository at this point in the history
Properly build marathon url
  • Loading branch information
LeoCavaille committed Feb 27, 2015
2 parents 8b69575 + c5dc9c7 commit c9fa9af
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions checks.d/marathon.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# stdlib
from urlparse import urljoin

# project
from checks import AgentCheck

Expand Down Expand Up @@ -31,15 +34,18 @@ 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']:
tags = ['app_id:' + app['id'], 'version:' + app['version']] + instance_tags
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)

Expand Down

0 comments on commit c9fa9af

Please sign in to comment.