Skip to content

Commit cc1febf

Browse files
committed
add docs on the metrics-as-json api
1 parent cbaf287 commit cc1febf

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

docs/monitoring.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,79 @@ making it easy to identify slow tasks, data skew, etc.
174174

175175
Note that the history server only displays completed Spark jobs. One way to signal the completion of a Spark job is to stop the Spark Context explicitly (`sc.stop()`), or in Python using the `with SparkContext() as sc:` to handle the Spark Context setup and tear down, and still show the job history on the UI.
176176

177+
## REST API
178+
179+
In addition to viewing the metrics in the UI, they are also available as JSON. This gives developers
180+
an easy way to create new visualizations and monitoring tools for Spark. The JSON is available for
181+
both running applications, an in the history server. The endpoints are mounted at `/json/v1`. Eg.,
182+
for the history server, they would typically be accessible at `http://<server_url>:18080/json/v1`.
183+
184+
<table class="table">
185+
<tr><th>Endpoint</th><th>Meaning</th></tr>
186+
<tr>
187+
<td>`/applications`</td>
188+
<td>A list of all applications</td>
189+
</tr>
190+
<tr>
191+
<td>`/applications/<app_id>/jobs`</td>
192+
<td>A list of all jobs for a given application</td>
193+
</tr>
194+
<tr>
195+
<td>`/applications/<app_id>/jobs/<job_id>`</td>
196+
<td>Details for one job</td>
197+
</tr>
198+
<tr>
199+
<td>`/applications/<app_id>/stages`</td>
200+
<td>A list of all stages for a given application</td>
201+
</tr>
202+
<tr>
203+
<td>`/applications/<app_id>/stages/<stage_id>`</td>
204+
<td>A list of all attempts for a given stage</td>
205+
</tr>
206+
<tr>
207+
<td>`/applications/<app_id>/stages/<stage_id>/<stage_attempt_id>`</td>
208+
<td>Details for the given stage attempt</td>
209+
</tr>
210+
<tr>
211+
<td>`/applications/<app_id>/stages/<stage_id>/<stage_attempt_id>/taskSummary`</td>
212+
<td>Summary metrics of all tasks in a stage attempt</td>
213+
</tr>
214+
<tr>
215+
<td>`/applications/<app_id>/stages/<stage_id>/<stage_attempt_id>/taskList`</td>
216+
<td>A list of all tasks for a given stage attempt</td>
217+
</tr>
218+
<tr>
219+
<td>`/applications/<app_id>/executors`</td>
220+
<td>A list of all executors for the given application</td>
221+
</tr>
222+
<tr>
223+
<td>`/applications/<app_id>/storage/rdd`</td>
224+
<td>A list of stored RDDs for the given application</td>
225+
</tr>
226+
<tr>
227+
<td>`/applications/<app_id>/storage/rdd/<rdd_id>`</td>
228+
<td>Details for the storage status of a given RDD</td>
229+
</tr>
230+
</table>
231+
232+
When running on Yarn, each application has multiple attempts, so `<app_id>` is really a compound key,
233+
with `<app_id>/<attempt_id>`.
234+
235+
These endpoints have been strongly versioned to make it easier to develop applications on top of these
236+
endpoints, without knowledge of spark internal classes. In particular, Spark guarantees:
237+
238+
* Endpoints will never be removed from one version
239+
* Individual fields will never be removed for any given endpoint
240+
* New endpoints may be added
241+
* New fields may be added to existing endpoints
242+
* New versions of the api may be added in the future, which are free to be completely incompatible with earlier versions
243+
* Api versions may be dropped, but only after at least one minor release of existing beside a new api version
244+
245+
Note that even when examining the UI of a running applications, the `applications/<app_id>` portion is
246+
still required, though there is only one application available. Eg. to see the list of jobs for the
247+
running app, you would go to `http://localhost:4040/json/v1/applications/<app_id>/jobs`. This is to
248+
keep the paths consistent in both modes.
249+
177250
# Metrics
178251

179252
Spark has a configurable metrics system based on the

0 commit comments

Comments
 (0)