首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >集装箱化的Prometheus无法抓取JMX-exporter

集装箱化的Prometheus无法抓取JMX-exporter
EN

Stack Overflow用户
提问于 2021-06-09 23:28:33
回答 1查看 165关注 0票数 1

我想为我的Spark应用程序添加指标,我使用JMX-exporter将指标公开给Prometheus。作为第一步,我希望看到Prometheus成功连接到JMX-exporter,并抓取一些现有的spark指标。我跟随this answer,执行以下命令:

代码语言:javascript
复制
spark-shell --conf "spark.driver.extraJavaOptions=-javaagent:jmx_prometheus_javaagent-0.10.jar=8888:.../spark.yml"

我找到了一个spark.yml文件here

当我访问http://localhost:8888/metrics时,我看到了很多指标,这是其中的一部分:

代码语言:javascript
复制
# HELP jvm_threads_current Current thread count of a JVM
# TYPE jvm_threads_current gauge
jvm_threads_current 57.0
# HELP jvm_threads_daemon Daemon thread count of a JVM
# TYPE jvm_threads_daemon gauge
jvm_threads_daemon 50.0
# HELP jvm_threads_peak Peak thread count of a JVM
# TYPE jvm_threads_peak gauge
jvm_threads_peak 58.0
# HELP jvm_threads_started_total Started thread count of a JVM
# TYPE jvm_threads_started_total counter
jvm_threads_started_total 60.0
# HELP jvm_threads_deadlocked Cycles of JVM-threads that are in deadlock waiting to acquire object monitors or ownable synchronizers
# TYPE jvm_threads_deadlocked gauge
jvm_threads_deadlocked 0.0
# HELP jvm_threads_deadlocked_monitor Cycles of JVM-threads that are in deadlock waiting to acquire object monitors
# TYPE jvm_threads_deadlocked_monitor gauge
jvm_threads_deadlocked_monitor 0.0
# HELP jmx_scrape_duration_seconds Time this JMX scrape took, in seconds.
# TYPE jmx_scrape_duration_seconds gauge
jmx_scrape_duration_seconds 0.018020101
# HELP jmx_scrape_error Non-zero if this scrape failed.
# TYPE jmx_scrape_error gauge
jmx_scrape_error 0.0
# HELP jvm_info JVM version info
# TYPE jvm_info gauge
jvm_info{version="11.0.9+11",vendor="Oracle Corporation",} 1.0
# HELP jmx_config_reload_failure_total Number of times configuration have failed to be reloaded.
# TYPE jmx_config_reload_failure_total counter
jmx_config_reload_failure_total 0.0
# HELP jmx_config_reload_success_total Number of times configuration have successfully been reloaded.
# TYPE jmx_config_reload_success_total counter
jmx_config_reload_success_total 0.0
# HELP jvm_memory_bytes_used Used bytes of a given JVM memory area.
# TYPE jvm_memory_bytes_used gauge
jvm_memory_bytes_used{area="heap",} 1.83810352E8
jvm_memory_bytes_used{area="nonheap",} 1.324068E8
# HELP jvm_memory_bytes_committed Committed (bytes) of a given JVM memory area.
# TYPE jvm_memory_bytes_committed gauge
jvm_memory_bytes_committed{area="heap",} 5.36870912E8
jvm_memory_bytes_committed{area="nonheap",} 1.39730944E8
# HELP jvm_memory_bytes_max Max (bytes) of a given JVM memory area.
# TYPE jvm_memory_bytes_max gauge
jvm_memory_bytes_max{area="heap",} 1.073741824E9
jvm_memory_bytes_max{area="nonheap",} -1.0
# HELP jvm_memory_pool_bytes_used Used bytes of a given JVM memory pool.
# TYPE jvm_memory_pool_bytes_used gauge
jvm_memory_pool_bytes_used{pool="CodeHeap 'non-nmethods'",} 1330816.0
jvm_memory_pool_bytes_used{pool="Metaspace",} 9.090232E7
jvm_memory_pool_bytes_used{pool="CodeHeap 'profiled nmethods'",} 2.3704192E7
jvm_memory_pool_bytes_used{pool="Compressed Class Space",} 1.1603552E7
jvm_memory_pool_bytes_used{pool="G1 Eden Space",} 7.2351744E7
jvm_memory_pool_bytes_used{pool="G1 Old Gen",} 9.3632816E7
jvm_memory_pool_bytes_used{pool="G1 Survivor Space",} 1.7825792E7
jvm_memory_pool_bytes_used{pool="CodeHeap 'non-profiled nmethods'",} 4865920.0
# HELP jvm_memory_pool_bytes_committed Committed bytes of a given JVM memory pool.
# TYPE jvm_memory_pool_bytes_committed gauge
jvm_memory_pool_bytes_committed{pool="CodeHeap 'non-nmethods'",} 2555904.0
jvm_memory_pool_bytes_committed{pool="Metaspace",} 9.490432E7
jvm_memory_pool_bytes_committed{pool="CodeHeap 'profiled nmethods'",} 2.3724032E7
jvm_memory_pool_bytes_committed{pool="Compressed Class Space",} 1.3631488E7
jvm_memory_pool_bytes_committed{pool="G1 Eden Space",} 2.71581184E8
jvm_memory_pool_bytes_committed{pool="G1 Old Gen",} 2.47463936E8
jvm_memory_pool_bytes_committed{pool="G1 Survivor Space",} 1.7825792E7
jvm_memory_pool_bytes_committed{pool="CodeHeap 'non-profiled nmethods'",} 4915200.0
# HELP jvm_memory_pool_bytes_max Max bytes of a given JVM memory pool.
# TYPE jvm_memory_pool_bytes_max gauge
jvm_memory_pool_bytes_max{pool="CodeHeap 'non-nmethods'",} 5836800.0
jvm_memory_pool_bytes_max{pool="Metaspace",} -1.0
jvm_memory_pool_bytes_max{pool="CodeHeap 'profiled nmethods'",} 1.22908672E8
jvm_memory_pool_bytes_max{pool="Compressed Class Space",} 1.073741824E9
jvm_memory_pool_bytes_max{pool="G1 Eden Space",} -1.0
jvm_memory_pool_bytes_max{pool="G1 Old Gen",} 1.073741824E9
jvm_memory_pool_bytes_max{pool="G1 Survivor Space",} -1.0
jvm_memory_pool_bytes_max{pool="CodeHeap 'non-profiled nmethods'",} 1.22912768E8
# HELP jvm_classes_loaded The number of classes that are currently loaded in the JVM
# TYPE jvm_classes_loaded gauge
jvm_classes_loaded 10829.0
# HELP jvm_classes_loaded_total The total number of classes that have been loaded since the JVM has started execution
# TYPE jvm_classes_loaded_total counter
jvm_classes_loaded_total 10829.0
# HELP jvm_classes_unloaded_total The total number of classes that have been unloaded since the JVM has started execution
# TYPE jvm_classes_unloaded_total counter
jvm_classes_unloaded_total 0.0
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 23.438644
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.623251436259E9
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 412.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 10240.0
# HELP jvm_gc_collection_seconds Time spent in a given JVM garbage collector in seconds.
# TYPE jvm_gc_collection_seconds summary
jvm_gc_collection_seconds_count{gc="G1 Young Generation",} 10.0
jvm_gc_collection_seconds_sum{gc="G1 Young Generation",} 0.257
jvm_gc_collection_seconds_count{gc="G1 Old Generation",} 0.0
jvm_gc_collection_seconds_sum{gc="G1 Old Generation",} 0.0 

我的prometheus.yml包含以下内容:

代码语言:javascript
复制
global:
  scrape_interval:     15s
  evaluation_interval: 15s

scrape_configs:
- job_name: prometheus
  static_configs:
  - targets: ['localhost:9090']

- job_name: "spark_streaming_app"
  scrape_interval: "5s"
  static_configs:
  - targets: ['localhost:8888']

当我转到位于localhost:9090/ target的Prometheus UI时,我可以看到prometheus target是up的,而spark_streaming_app是down的。在我看来,这些指标在localhost:8888上显示成功,但普罗米修斯未能成功获取它们。

你知道我做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2021-11-07 16:38:06

普罗米修斯是“容器化的”,容器的localhost就是容器本身。因此,端口8888上没有任何东西可供普罗米修斯从抓取指标。

如果您使用的是Docker Desktop (MacOS/Windows),那么对于在主机上运行的目标,在prometheus.yml中使用host.docker.internal而不是localhost

在Linux上,以主机网络模式运行Prometheus容器,无需更改配置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67907263

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档