dd-agent icon indicating copy to clipboard operation
dd-agent copied to clipboard

Marathon URL can't contain a path

Open ensonik opened this issue 10 years ago • 3 comments

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.

ensonik avatar Jun 20 '16 19:06 ensonik

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.

degemer avatar Jun 22 '16 18:06 degemer

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?

ensonik avatar Jun 23 '16 13:06 ensonik

Thanks for the details! We'll be happy to review your PR.

degemer avatar Jun 23 '16 14:06 degemer