-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24594][YARN] Introducing metrics for YARN #21635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
9b033cc
4968ad6
9735525
a8f3146
b0ee4ec
68ba47e
f3781bd
6751ec5
c0c4748
7958525
6761098
0b86788
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ import org.apache.spark.deploy.yarn.config._ | |
| import org.apache.spark.deploy.yarn.security.AMCredentialRenewer | ||
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.internal.config._ | ||
| import org.apache.spark.metrics.MetricsSystem | ||
| import org.apache.spark.rpc._ | ||
| import org.apache.spark.scheduler.cluster.{CoarseGrainedSchedulerBackend, YarnSchedulerBackend} | ||
| import org.apache.spark.scheduler.cluster.CoarseGrainedClusterMessages._ | ||
|
|
@@ -67,6 +68,8 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends | |
|
|
||
| private val securityMgr = new SecurityManager(sparkConf) | ||
|
|
||
| private var metricsSystem: MetricsSystem = _ | ||
|
|
||
| // Set system properties for each config entry. This covers two use cases: | ||
| // - The default configuration stored by the SparkHadoopUtil class | ||
| // - The user application creating a new SparkConf in cluster mode | ||
|
|
@@ -309,6 +312,9 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends | |
| finish(FinalApplicationStatus.FAILED, | ||
| ApplicationMaster.EXIT_UNCAUGHT_EXCEPTION, | ||
| "Uncaught exception: " + StringUtils.stringifyException(e)) | ||
| } finally { | ||
| metricsSystem.report() | ||
|
||
| metricsSystem.stop() | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -434,6 +440,9 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends | |
| rpcEnv.setupEndpoint("YarnAM", new AMEndpoint(rpcEnv, driverRef)) | ||
|
|
||
| allocator.allocateResources() | ||
| metricsSystem = MetricsSystem.createMetricsSystem("yarn", sparkConf, securityMgr) | ||
| metricsSystem.registerSource(new YarnClusterSchedulerSource(allocator)) | ||
| metricsSystem.start() | ||
| reporterThread = launchReporterThread() | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.deploy.yarn | ||
|
|
||
| import com.codahale.metrics.{Gauge, MetricRegistry} | ||
|
|
||
| import org.apache.spark.metrics.source.Source | ||
|
|
||
| private[spark] class YarnClusterSchedulerSource(yarnAllocator: YarnAllocator) extends Source { | ||
|
|
||
| override val sourceName: String = "yarn" | ||
| override val metricRegistry: MetricRegistry = new MetricRegistry() | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numExecutorsFailed"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.getNumExecutorsFailed | ||
| }) | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numExecutorsRunning"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.getNumExecutorsRunning | ||
| }) | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numReleasedContainers"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.getNumReleasedContainers | ||
| }) | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numPendingLossReasonRequests"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.getNumPendingLossReasonRequests | ||
|
||
| }) | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numLocalityAwareTasks"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.numLocalityAwareTasks | ||
| }) | ||
|
|
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The size of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I have seen the call goes to YARN and I also was afraid abut its execution time so this is why I finally decided to leave it out. But I will check whether there is something better to get it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The getPendingAllocate seams to me quite cheap as it just uses local maps (and tables) to calculate a list of ContainerRequests. |
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add yarn to the monitoring.md doc as component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Tom, documentation is added.