简体   繁体   English

将 Spark 指标推送到 Prometheus

[英]Push Spark metrics to Prometheus

How can I set Spark to push metrics to Prometheus?如何设置 Spark 以将指标推送到 Prometheus? like it sends to Graphite for example.例如,它发送到 Graphite。

Of course, I don't care about using the Prometheus push getaway but how do I get Spark to send those metrics (and not just expose them at an endpoint)?当然,我不关心使用 Prometheus push getaway,但我如何让 Spark 发送这些指标(而不仅仅是在端点上公开它们)?

BanzaiCloud have an implementation of Prometheus push gateway sink for spark metrics You can view the full guide here: https://github.com/banzaicloud/spark-metrics/blob/master/PrometheusSink.md EDIT: The current build is for Spark 2.XI never tried it on Spark 3.X but I it could works just fine since I dont recall any major changes in the metrics system BanzaiCloud 实现了用于 Spark 指标的 Prometheus 推送网关接收器您可以在此处查看完整指南: https://github.com/banzaicloud/spark-metrics/blob/master/PrometheusSink.md编辑:当前版本适用于 Spark 2 .XI 从未在 Spark 3.X 上尝试过,但我认为它可以正常工作,因为我不记得指标系统有任何重大变化

Basically you need to do 2 thing:基本上你需要做两件事:

  1. set the spark metrics sink to the push gateway server metrics.properties (copied the snippet from the guide):将 spark 指标接收器设置为推送网关服务器 metrics.properties(从指南复制片段):
 # Enable Prometheus for all instances by class name
*.sink.prometheus.class=org.apache.spark.banzaicloud.metrics.sink.PrometheusSink
# Prometheus pushgateway address
*.sink.prometheus.pushgateway-address-protocol=<prometheus pushgateway protocol> - defaults to http
*.sink.prometheus.pushgateway-address=<prometheus pushgateway address> - defaults to 127.0.0.1:9091
*.sink.prometheus.period=<period> - defaults to 10
*.sink.prometheus.unit=< unit> - defaults to seconds (TimeUnit.SECONDS)
*.sink.prometheus.pushgateway-enable-timestamp=<enable/disable metrics timestamp> - defaults to false

# There are more options in the guide
  1. Add their spark-metris jar to your app using --jars <path to jar> (by downloading it from maven central) or --packages <groupId:artifactId:version> (which pulls it from maven centeral or other custom repo using --repositories <url> ) in the spark-submit command also add the metrics.properties file to the deployment using --files /path/to/metrics.properties Add their spark-metris jar to your app using --jars <path to jar> (by downloading it from maven central) or --packages <groupId:artifactId:version> (which pulls it from maven centeral or other custom repo using --repositories <url> )在 spark-submit 命令中还使用--files /path/to/metrics.properties将 metrics.properties 文件添加到部署中
# Using packages
spark-submit ... --packages com.banzaicloud:spark-metrics_2.12:2.4-1.0.6 --files /path/to/metrics.properties ...

# Using JAR
spark-submit ... --jars /path/to/spark-metrics_2.12-2.4-1.0.6.jar --files /path/to/metrics.properties ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM