繁体   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