关注 spark技术分享,
撸spark源码 玩spark最佳实践

Spark Metrics

Spark Metrics

Spark Metrics gives you execution metrics of Spark subsystems (aka metrics instances), e.g. the driver of a Spark application or the master of a Spark Standalone cluster.

Spark Metrics uses Dropwizard Metrics 3.1.0 Java library for the metrics infrastructure.

Metrics is a Java library which gives you unparalleled insight into what your code does in production.

Metrics provides a powerful toolkit of ways to measure the behavior of critical components in your production environment.

MetricsSystem — Registry of Metrics Sources and Sinks of Spark Subsystem

The main part of Spark Metrics is MetricsSystem which is a registry of metrics sources and sinks of a Spark subsystem.

MetricsSystem uses Dropwizard Metrics’ MetricRegistry that acts as the integration point between Spark and the metrics library.

A Spark subsystem can access the MetricsSystem through the SparkEnv.metricsSystem property.

MetricsConfig — Metrics System Configuration

MetricsConfig is the configuration of the MetricsSystem (i.e. metrics sources and sinks).

metrics.properties is the default metrics configuration file. It is configured using spark.metrics.conf configuration property. The file is first loaded from the path directly before using Spark’s CLASSPATH.

MetricsConfig also accepts a metrics configuration using spark.metrics.conf.-prefixed configuration properties.

Spark comes with conf/metrics.properties.template file that is a template of metrics configuration.

MetricsServlet Metrics Sink

Among the metrics sinks is MetricsServlet that is used when sink.servlet metrics sink is configured in metrics configuration.

Caution
FIXME Describe configuration files and properties

JmxSink Metrics Sink

Enable org.apache.spark.metrics.sink.JmxSink in metrics configuration.

You can then use jconsole to access Spark metrics through JMX.

spark metrics jconsole.png
Figure 1. jconsole and JmxSink in spark-shell

JSON URI Path

Metrics System is available at http://localhost:4040/metrics/json (for the default setup of a Spark application).

Note
You can access a Spark subsystem’s MetricsSystem using its corresponding “leading” port, e.g. 4040 for the driver, 8080 for Spark Standalone’s master and applications.
Note
You have to use the trailing slash (/) to have the output.

Spark Standalone Master

赞(0) 打赏
未经允许不得转载:spark技术分享 » Spark Metrics
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏