Monitoring Java processes with Prometheus

Monitoring Java processes with Prometheus

Tokuhiro Matsuno
LINE Corp

Who am I?

  • Working at LINE Corp.
  • I’m writing web applications in Java 8
  • Author of promgen(Ruby version)
  • CPAN Author

Contributor of the client_java

Why Prometheus?

  • Store the metrics values
  • Prometheus provides querying features.
  • Render it using query
  • Grafana is awesome

Monitoring Java processes with Prometheus

There are some options
  • Dropwizard metrics → client_java
  • client_java(In process jetty)

jmx_prometheus_javaagent

  • Aggregate metrics values using JMX
  • -javaagent:jmx_prometheus_javaagent.jar=1234:config.yaml
  • Easy to setup
  • If it uses too much CPU time, application may get performance issue
  • relabeling is hard
  • in YAML

---
hostPort: 127.0.0.1:1234
jmxUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:1234/jmxrmi
lowercaseOutputName: false
lowercaseOutputLabelNames: false
whitelistObjectNames: ["org.apache.cassandra.metrics:*"]
blacklistObjectNames: ["org.apache.cassandra.metrics:type=ColumnFamily,*"]
rules:
  - pattern: "^org.apache.cassandra.metrics<type=(\w+), name=(\w+)><>Value: (\d+)"
    name: cassandra_$1_$2
    value: $3
    valueFactor: 0.001
    labels: {}
    help: "Cassandra metric $1 $2"
    type: GAUGE