Date
cd /root/tomcat/bin
wget "https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.11.0/jmx_prometheus_javaagent-0.11.0.jar"
cat > config.yml <<EOF
startDelaySeconds: 0
ssl: false
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
    attrNameSnakeCase: false
EOF
vi catalina.sh
JAVA_OPTS="${JAVA_OPTS} -javaagent:/root/tomcat/bin/jmx_prometheus_javaagent-0.11.0.jar=7070:/root/tomcat/bin/config.yml"
sh catalina.sh run
docker exec 88 tail -n 3 /etc/prometheus/prometheus.yml
  - job_name: 'tomcat'
    static_configs:
      - targets: ['192.168.2.2222:7070']

访问http://192.168.2.222:9090/graph验证

原文地址:
https://github.com/prometheus/jmx_exporter
https://stackoverflow.com/questions/47531507/jmx-exporter-shows-error-in-prometheus-grafana


Comments