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

Properly build marathon url #1401

Merged
merged 1 commit into from
Feb 27, 2015
Merged
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
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