如何将Spark指标发送到独立群集上的Graphite?

时间:2015-11-09 15:23:10

标签: apache-spark metrics graphite

我尝试使用以下配置将Spark指标发送到Graphite:

*.sink.graphite.class=org.apache.spark.metrics.sink.GraphiteSink
*.sink.graphite.host=85.10.206.170
*.sink.graphite.port=2003
*.sink.graphite.period=1
*.sink.graphite.unit=minutes

# Enable jvm source for instance master, worker, driver and executor
master.source.jvm.class=org.apache.spark.metrics.source.JvmSource

worker.source.jvm.class=org.apache.spark.metrics.source.JvmSource

driver.source.jvm.class=org.apache.spark.metrics.source.JvmSource

executor.source.jvm.class=org.apache.spark.metrics.source.JvmSource

application.source.jvm.class=org.apache.spark.metrics.source.JvmSource

保存在/data/configurations/metrics.properties

我使用以下属性提交我的申请:

--files=/data/configuration/metrics.properties --conf spark.metrics.conf=metrics.properties

我收到以下错误:

com.test.MyApp: metrics.properties (No such file or directory)
 java.io.FileNotFoundException: metrics.properties (No such file or directory)
    at java.io.FileInputStream.open0(Native Method) ~[?:1.8.0_45]
    at java.io.FileInputStream.open(FileInputStream.java:195) ~[?:1.8.0_45]
    at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[?:1.8.0_45]
    at java.io.FileInputStream.<init>(FileInputStream.java:93) ~[?:1.8.0_45]
    at org.apache.spark.metrics.MetricsConfig$$anonfun$1.apply(MetricsConfig.scala:50) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.metrics.MetricsConfig$$anonfun$1.apply(MetricsConfig.scala:50) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at scala.Option.map(Option.scala:145) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.metrics.MetricsConfig.initialize(MetricsConfig.scala:50) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.metrics.MetricsSystem.<init>(MetricsSystem.scala:93) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.metrics.MetricsSystem$.createMetricsSystem(MetricsSystem.scala:222) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.SparkEnv$.create(SparkEnv.scala:361) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.SparkEnv$.createDriverEnv(SparkEnv.scala:188) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.SparkContext.createSparkEnv(SparkContext.scala:267) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.SparkContext.<init>(SparkContext.scala:424) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.streaming.StreamingContext$.createNewSparkContext(StreamingContext.scala:842) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.streaming.StreamingContext.<init>(StreamingContext.scala:80) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]
    at org.apache.spark.streaming.api.java.JavaStreamingContext.<init>(JavaStreamingContext.scala:133) ~[spark-assembly-1.4.1-hadoop2.4.0.jar:1.4.1]

我哪里错了?

1 个答案:

答案 0 :(得分:3)

tl; dr spark.metrics.conf应该是绝对路径。

注意:星号(*)指的是Spark中可用的任何指标源,可以是driverexecutor,外部shuffleServicemasterapplicationsworkermesos_cluster

提示:您可以使用相应的服务网址访问指标,例如: 4040用于驱动程序,8080用于Spark Standalone的主服务器和应用程序,使用http://localhost:[port]/metrics/json/ URL。