I am developing a UI in which I need to show the live logs (stdout and stderr) of jobs running in a mesos slave. I am finding out a way in which I will be able to generate a URL which will point to the mesos logs for the job. Is there a way to do the same? Basically, I need to know the slave id, executor id, master id etc. for generating the URL. Is there a way to find these information?
3 Answers
The sandbox URL is of the form http://
$slave_url:5050/read.json?$work_dir/work/slaves/$slave_id/frameworks/$framework_id/executors/$executor_id/runs/$container_id/stdout
, and you can even use the browse.json
endpoint to browse around within the sandbox.
Alternatively, you can use the mesos tail $task_id
CLI command to access these logs.
For more details, see the following mailing list thread: http://search-hadoop.com/m/RFt15skyLE/Accessing+stdout%252Fstderr+of+a+task+programmattically

- 4,322
- 1
- 16
- 22
How about using reverse approach. You need to present live logs from stderr and stdout. How about storing them outside of mesos slave e.g., elastic-search? You will get nearly live updates, old logs available after, nice search options.
From version 0.27.0 Mesos supports ContainerLogger. You can write your own implementation of ContainerLogger that will push logs to central logs repository (Graylog, Logstash, e.t.c) and then expose it in your UI.

- 6,292
- 4
- 37
- 70
-
Thank you, I think your answer is the best so far. It sucks that Mesos doesn't provide this automatically, though. – static_rtti Jul 20 '16 at 15:56
-
1At least there was a try at [MesosCon hackaton](https://github.com/joyent/mesoscon-eu-2015-hackathon/blob/master/log-forwarding.md) but I'm not sure if it gets production ready. You can find more people interested in this feature on [Mesos users mailing list](https://mail-archives.apache.org/mod_mbox/mesos-user/201409.mbox/
). – janisz Jul 20 '16 at 16:10
Mesos offers a REST interface where you get the information you want. Visit with your browser http://<MESOS_MASTER_IP>:5050/help
(using default port) to check the options you have to query (for example, you can get the information you need from http://<MESOS_MASTER_IP>:5050/master/state.json)
. Check this link to see an example using it.

- 8,851
- 3
- 26
- 27
-
1Hi, thanks for ur quick reponse! I am able to get all the info except container id from /master/state.json.. Is there a way to get the container id? – Surya Kaleeswaran Feb 24 '15 at 13:55
-
1