In Hadoop2, is it possible to use the rest API to get the same result as:
yarn logs -applicationId <application ID>
Try "yarn application -list" to get a list of all Yarn apps, followed by "yarn logs -applicationId" to get logs for a particular app. You can find details about these and other yarn commands here.
Yarn logs are aggregated into HDFS directory '/app-logs/<user_name>/logs'. Refer link for more details on log aggregation.
This is a pain and I don't have a happy answer, but I can point you to some resources.
The YARN CLI dumps logs by going to the file system. If your application can access HDFS, it can do the same thing (but it's not simple).
Alternatively, you can get the application master log URL (but not the log contents) using the rest call http:///ws/v1/cluster/apps/{appid}. From this URL, you can fetch an HTML page with the log contents, which will be returned in a <pre>
tag with encoded HTML entities (&
etc).
If your application is still running, you can get the raw logs using the container id from the above URL: http:///ws/v1/node/containerlogs/{containerId}/stdout. This was implemented as part of YARN-649.
YARN-1264 looks like exactly what you want, but was Closed-Duplicate with the above JIRA. That wasn't quite accurate, since the CLI and web page can get the logs after the container is finished, but the REST service above can't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With