how can I access to the chronos api?

840 views Asked by At

I have a mesos and chronos environment, I want to use chronos api to monitor jobs status, But ...

curl -L http://localhost:8080/leader

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 </title>
</head>
<body>
<h2>HTTP ERROR: 404</h2>
<p>Problem accessing /leader. Reason:
<pre>    Not Found</pre></p>
<hr /><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.3.z-SNAPSHOT</a><hr/>
</body>
</html>

It return 404 to me,Can anybody has ideas? The other features work fine. web ui job status The API URL is : chronos REST API DOC

1

There are 1 answers

0
aweigold On

You'll need to ensure you are connecting to the correct host on your cluster. It's likely chronos is not accessible via localhost or chronos-node given you are not receiving a response.

To determine where chronos is running, leverage mesos dns.

If your service is installed as chronos, look up the SRV record for all TCP endpoints as follows:

/# dig _chronos._tcp.marathon.mesos SRV

; <<>> DiG 9.12.1-P2 <<>> _chronos._tcp.marathon.mesos SRV
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39584
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;_chronos._tcp.marathon.mesos.  IN      SRV

;; ANSWER SECTION:
_chronos._tcp.marathon.mesos. 60 IN     SRV     0 0 9669 chronos-jjmux-s11.marathon.mesos.

;; ADDITIONAL SECTION:
chronos-jjmux-s11.marathon.mesos. 60 IN A       10.0.2.15

;; Query time: 1 msec
;; SERVER: 198.51.100.1#53(198.51.100.1)
;; WHEN: Tue Oct 02 22:48:02 UTC 2018
;; MSG SIZE  rcvd: 114

In this case above, I installed via the DC/OS universe, which automatically deploys with any available port via the host network driver, however I see there is a tcp listener on port 9669 via the DNS query. From there you can receive a response via curl -L -X GET http://chronos.marathon.mesos:9669/scheduler/jobs. (note:, the chronos documentation states to prefix with /v1, however in some deployments, that will not be the case).

Lastly, you'll likely not want to perform a lookup of an SRV record every time. If you installed via the DC/OS universe, chronos is deployed via marathon, however the universe package hides all the configuration options necessary to define a VIP via the DC/OS interface. This can be addressed by manually going to the original marathon interface, where you'll be able to change the configuration (or via the marathon api).