Как я могу контролировать мой образ Кассандры Докер с помощью Prometheus?

Я пытаюсь отследить экземпляр докера cassandra с экземпляра докера Prometheus.

Я запутался, поскольку кажется, что есть много возможностей и пакетов для этого.

Прямо сейчас Прометей говорит: Get http://127.0.0.1:7070/metrics: dial tcp 127.0.0.1:7070: getsockopt: connection refused

Я пытался найти учебник, чтобы помочь мне, но есть так много людей с другим подходом.

Кассандра Докерфайл:

FROM cassandra:3.11.2

ENV LOCAL_JMX no
COPY jmxremote.password /etc/cassandra/jmxremote.password
COPY jmxremote.access /etc/cassandra/jmxremote.access
RUN chown cassandra:cassandra /etc/cassandra/jmxremote.*
RUN chmod 400 /etc/cassandra/jmxremote.*

RUN sed -i 's/#JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.access.file=\/etc\/cassandra\/jmxremote.access"/JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.access.file=\/etc\/cassandra\/jmxremote.access"/g' /etc/cassandra/cassandra-env.sh
RUN sed -i 's/# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=127.0.0.1"/JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=${JMX_HOST:-localhost}"/g' /etc/cassandra/cassandra-env.sh

докер-compose.yml

version: '3.1'

networks:
  front-tier:
  back-tier:

services:
  prometheus:
      image: prom/prometheus:v2.1.0
      volumes:
        - ./prometheus/:/etc/prometheus/
        - ./prometheus_data:/prometheus:rw
      command:
        - '--config.file=/etc/prometheus/prometheus.yml'
        - '--storage.tsdb.path=/prometheus'
        - '--web.console.libraries=/usr/share/prometheus/console_libraries'
        - '--web.console.templates=/usr/share/prometheus/consoles'
      ports:
        - 9090:9090
      links:
        - cadvisor:cadvisor
        - alertmanager:alertmanager
      depends_on:
        - cadvisor
      networks:
        - back-tier
      #restart: always
  #    deploy:
  #      placement:
  #        constraints:
  #          - node.hostname == ${HOSTNAME}

  node-exporter:
    image: prom/node-exporter
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command: 
      - '--path.procfs=/host/proc' 
      - '--path.sysfs=/host/sys'
      - --collector.filesystem.ignored-mount-points
      - "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
    ports:
      - 9100:9100
    networks:
      - back-tier
    #restart: always
    deploy:
      mode: global

  alertmanager:
    image: prom/alertmanager
    ports:
      - 9093:9093
    volumes:
      - ./alertmanager/:/etc/alertmanager/
    networks:
      - back-tier
    #restart: always
    command:
      - '--config.file=/etc/alertmanager/config.yml'
      - '--storage.path=/alertmanager'
#    deploy:
#      placement:
#        constraints:
#          - node.hostname == ${HOSTNAME}
  cadvisor:
    image: google/cadvisor
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
    ports:
      - 8080:8080
    networks:
      - back-tier
    restart: always
    deploy:
      mode: global

  grafana:
    image: grafana/grafana
    user: "104"
    depends_on:
      - prometheus
    ports:
      - 3000:3000
    volumes:
      - ./grafana_data:/var/lib/grafana:rw
      - ./grafana/provisioning/:/etc/grafana/provisioning/
    env_file:
      - ./grafana/config.monitoring
    networks:
      - back-tier
      - front-tier
    #restart: always

    #
    # Datacenter 1 seed node
    #
  cassandra_dc1nd1s:
    build: ./cassandra
    environment:
        - DATACENTER=DC1
    ports:
        - "9042:9042"
        - "9160:9160"
        - "7070:7070"
    networks:
        - back-tier
        - front-tier
    volumes:
      - ./cassandra_data:/var/lib/cassandra:rw
      - ./cassandra/cassandra.yml:/etc/cassandra/cassandra.yml

prometheus.yml скрести конфиг:

  - job_name: 'cassandra'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 10s
    basic_auth:
      username: 'prometheus'
      password: 'abcde123456'
    static_configs:
     - targets: ['127.0.0.1:7070']

0 ответов

Другие вопросы по тегам