User Tools

Site Tools


Writing /app/www/public/data/meta/toolsandtechnologies/jmx_prometheus_exporter.meta failed
toolsandtechnologies:jmx_prometheus_exporter

JMX Prometheus Exporter Set Up

Download the jmx_prometheus_javaagent.jar.

  • Move the downloaded jar to a directory on the handler running the application you wish to monitor.
  • In same directory create a config.yaml file. (Basic example config shown below)
ssl: false
lowercaseOutputName: false
lowercaseOutputLabelNames: false
whitelistObjectNames: ["org.apache.cassandra.metrics:*"]
blacklistObjectNames: ["org.apache.cassandra.metrics:type=ColumnFamily,*"]
  • vi into the startup.sh file for the application you wish to monitor.
  • Add the following lines inside the JAVA_OPTS.
-javaagent:/PATH/TO/JAR/jmx_prometheus_javaagent-0.10.jar=PORTNUMBER:/PATH/TO/CONFIG/config.yaml \
-Dcom.sun.management.jmxremote=true \
-Dcom.sun.management.jmxremote.ssl=false \
  • Replace the paths to point to the jar and the config file for the exporter.
  • Replace PORTNUMBER with the port number you want your endpoint on.
  • Save and quit.
  • To start the exporter requires an application restart.
  • To verify the metrics are exposed you can view them in the browser or on the command line of the app handler:
  • Following this you should see output similar to below.
# 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 jvm_memory_bytes_used Used bytes of a given JVM memory area.
# TYPE jvm_memory_bytes_used gauge
jvm_memory_bytes_used{area="heap",} 5.88200304E8
jvm_memory_bytes_used{area="nonheap",} 1.00708664E8
# 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",} 2.669674496E9
jvm_memory_bytes_committed{area="nonheap",} 2.8246016E8
# 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",} 2.669674496E9
jvm_memory_bytes_max{area="nonheap",} 3.18767104E8
# 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="Code Cache",} 1.3843776E7
jvm_memory_pool_bytes_used{pool="PS Eden Space",} 4.35325472E8
jvm_memory_pool_bytes_used{pool="PS Survivor Space",} 1769472.0
jvm_memory_pool_bytes_used{pool="PS Old Gen",} 1.5110536E8
jvm_memory_pool_bytes_used{pool="PS Perm Gen",} 8.6864888E7
# 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="Code Cache",} 1.4024704E7
jvm_memory_pool_bytes_committed{pool="PS Eden Space",} 8.85522432E8
jvm_memory_pool_bytes_committed{pool="PS Survivor Space",} 2621440.0
jvm_memory_pool_bytes_committed{pool="PS Old Gen",} 1.781530624E9
jvm_memory_pool_bytes_committed{pool="PS Perm Gen",} 2.68435456E8
# 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="Code Cache",} 5.0331648E7
jvm_memory_pool_bytes_max{pool="PS Eden Space",} 8.85522432E8
jvm_memory_pool_bytes_max{pool="PS Survivor Space",} 2621440.0
jvm_memory_pool_bytes_max{pool="PS Old Gen",} 1.781530624E9
jvm_memory_pool_bytes_max{pool="PS Perm Gen",} 2.68435456E8
# HELP jvm_classes_loaded The number of classes that are currently loaded in the JVM
# TYPE jvm_classes_loaded gauge
jvm_classes_loaded 13164.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 13957.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 793.0
# HELP jmx_scrape_duration_seconds Time this JMX scrape took, in seconds.
# TYPE jmx_scrape_duration_seconds gauge
jmx_scrape_duration_seconds 6.1745E-5
# HELP jmx_scrape_error Non-zero if this scrape failed.
# TYPE jmx_scrape_error gauge
jmx_scrape_error 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 1308.58
# 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.507297514844E9
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 61.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 4096.0
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 1.1074588672E10
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.434279936E9
# 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_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="PS Scavenge",} 233.0
jvm_gc_collection_seconds_sum{gc="PS Scavenge",} 2.566
jvm_gc_collection_seconds_count{gc="PS MarkSweep",} 72.0
jvm_gc_collection_seconds_sum{gc="PS MarkSweep",} 15.335
# HELP jvm_threads_current Current thread count of a JVM
# TYPE jvm_threads_current gauge
jvm_threads_current 95.0
# HELP jvm_threads_daemon Daemon thread count of a JVM
# TYPE jvm_threads_daemon gauge
jvm_threads_daemon 72.0
# HELP jvm_threads_peak Peak thread count of a JVM
# TYPE jvm_threads_peak gauge
jvm_threads_peak 96.0
# HELP jvm_threads_started_total Started thread count of a JVM
# TYPE jvm_threads_started_total counter
jvm_threads_started_total 967.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 jvm_info JVM version info
# TYPE jvm_info gauge
jvm_info{version="1.7.0_80-b15",vendor="Oracle Corporation",} 1.0
  • vi into your prometheus.yml file
  • Under “scrape configs” add your new target
  - job_name: 'NocPortal'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ['HOSTNAME:PORTNUMBER']
  • Replace 'HOSTNAME' and 'PORTNUMBER' with the appropriate hostname and port number you selected for the agent.
  • Save and quit
  • Start prometheus
  • Prometheus config can also be refreshed in stead of restarting - • curl –X POST http://localhost:9090/-/reload
  • In the prometheus UI select the “Status” dropdown from the navbar, then “Targets”.
  • You should see your target showing as “UP” similar to below

toolsandtechnologies/jmx_prometheus_exporter.txt · Last modified: 2021/06/25 10:09 by 127.0.0.1