Monitoring Elassandra with Prometheus using Docker

2019-08-28 01:43发布

I'm trying to run jmx-exporter container with special configuration following this instruction.

I did all the instructions step-by-step. Here is my docker-compose file and conf/config.yml.

docker-compose:

version: '2'
services:
  prometheus:
    image: prom/prometheus
    container_name: prometheus
    volumes:
      - /prometheus:/prometheus
      - ./conf/prome.yml:/etc/prometheus/prometheus.yml
    command:
      - --config.file=/etc/prometheus/prometheus.yml
    ports:
      - '6009:9090'

  jmx-exporter:
    image: sscaling/jmx-prometheus-exporter
    container_name: jmx-exporter
    ports:
      - 6011:5556
    depends_on:
       - elassandra

  elassandra:
    image: strapdata/elassandra
    container_name: elassandra
    volumes:
      - /var/lib/cassandra:/var/lib/cassandra
    environment:
      - CASSANDRA_LISTEN_ADDRESS=localhost
      - CASSANDRA_RPC_ADDRESS=localhost
      - CASSANDRA_START_RPC=false
      - CASSANDRA_CLUSTER_NAME='DockerTest Cluster'
      - CASSANDRA_NUM_TOKENS=8
      - CASSANDRA#
      - LOCAL_JMX="no"
      - Dcassandra.jmx.remote.port="7199"
      - Dcom.sun.management.jmxremote.port="7199"
      - Dcom.sun.management.jmxremote.rmi.port="7199"
      - Dcom.sun.management.jmxremote.authenticate=false 

      - JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=127.0.0.1"
      - JMX_PORT="7199"
      - JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.remote.port=5556"
      - JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=5556"
      - JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"

volumes:
        prometheus_data: {}
        elassandra_data: {}

conf/config.yml

startDelaySeconds: 0
hostPort: elassandra:7199
#username: 
#password: 
#jmxUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:60/jmxrmi
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

whenever I run docker-compose -f docker-compose.yml up, I face with the following page on localhost:6011:

enter image description here

The problem is that I don't know how to monitor elassandra and its metrics using jmx-exporter, I mainly get the java metrics!

1条回答
爷的心禁止访问
2楼-- · 2019-08-28 02:31

In your config.yml you're using hostPort: localhost:5556 but you should try to connect to the host elassandra (the name of your docker container in your docker-compose.yml file).

Make sure Elassandra is configured properly to allow remote JMX connections. See How to enable remote JMX connections in Elassandra? for details how to set that up.

查看更多
登录 后发表回答