簡體   English   中英

Mongodb Exporter不使用Docker和Prometheus顯示指標

[英]Mongodb Exporter doesn't Show the Metrics Using Docker and Prometheus

我正在嘗試從本頁面中看到的教程中對mongodb監控進行docker化。

這是我的Dockerfile配置:

FROM alpine
RUN apk update && apk add wget && rm -rf /var/cache/apk/*
RUN wget https://github.com/dcu/mongodb_exporter/releases/download/v1.0.0/mongodb_exporter-linux-amd64
RUN chmod 777 mongodb_exporter-linux-amd64
EXPOSE 9001

Prometheus.yml:

global:
    scrape_interval: 15s
    external_labels:
        monitor: 'my-monitor'
scrape_configs:
    - job_name: 'mongodb-exporter'
      static_configs:
          - targets: ['mongodb-exporter:9001']

docker-compose.yml:

version: '3'

services: 
  mongo:
    image: mongo
    container_name: mongo
    restart: always
    environment: 
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example

  prometheus:
    image: prom/prometheus
    restart: always
    ports:
      - 9090:9090
    volumes:
      - /home/mostafa/Desktop/docker_lab/mongo/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
    command: 
      - '--config.file=/etc/prometheus/prometheus.yml'

  mongodb-exporter:
    build: .
    command: ./mongodb_exporter-linux-amd64 -logtostderr -mongodb.uri mongodb://root:example@mongo:27017 -groups.enabled 'asserts,durability,background_flusshing,connections,extra_info,global_lock,index_counters,network,op_counters,op_counters_repl,memory,locks,metrics'
    restart: always
    ports: 
      - 9001:9001

1 mongodb_collector.go:70]收集操作日志狀態

1 oplog_status.go:127]無法獲取local.oplog_rs集合統計信息。

我應該看到的指標是這個,但現在我只看到以下指標。

我的指標

運行mongodb_exporter時使用的IP /主機名錯誤。

嘗試使用docker-compose.yml文件中的Mongo數據庫容器名稱代替127.0.0.1 ,在本例中為mongo

完整的URI應該是: mongodb://root:example@mongo:27017

關於Failed to get local.oplog_rs collection stats. 錯誤,您需要為用於刮取數據庫的用戶帳戶授予適當的權限,請參閱此博客文章中的詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM