Marathon URL can't contain a path
Inside Mesosphere the marathon url contains a path. This unfortunately doesn't work with the urljoin() found in the marathon check.
For example, my url is: http://marathon.mesos/service/marathon
Running this through url join (as it is in the check), I get the following:
>>> urljoin("http://marathon.mesos/service/marathon", "/v2/apps")
'http://marathon.mesos/v2/apps'
>>> urljoin("http://marathon.mesos/service/marathon/", "/v2/apps")
'http://marathon.mesos/v2/apps'
Obviously, the check fails with a 404.
You're right, I think there is an easy way to fix this, according to http://stackoverflow.com/a/1794540. This works:
>>> urljoin("http://marathon.mesos/service/marathon/", "v2/apps")
'http://marathon.mesos/service/marathon/v2/apps'
Could you try this locally to confirm (replace '/v2/apps by v2/apps there https://github.com/DataDog/dd-agent/blob/master/checks.d/marathon.py#L50) ? You can edit the check in /opt/datadog-agent/agent/checks.d/marathon.py and then restart the agent.
It works. I updated the marathon.py script with v2/apps instead of /v2/apps and it works in all cases (as long as the base URL has a trailing slash if there's a path).
The repl confirms.
>>> urljoin("http://marathon.mesos/service/marathon", "/v2/apps")
'http://marathon.mesos/v2/apps'
>>> urljoin("http://marathon.mesos/service/marathon/", "v2/apps")
'http://marathon.mesos/service/marathon/v2/apps'
>>> urljoin("http://marathon.mesos/service/marathon", "v2/apps")
'http://marathon.mesos/service/v2/apps'
>>> urljoin("http://marathon.mesos", "v2/apps")
'http://marathon.mesos/v2/apps'
>>> urljoin("http://marathon.mesos/", "v2/apps")
'http://marathon.mesos/v2/apps'
Do you want a PR?
Thanks for the details! We'll be happy to review your PR.