kubernetes Mongodb_exporter只导出一个mongodb指标(--collect-all处于打开状态)

fdx2calv  于 2023-03-01  发布在  Kubernetes
关注(0)|答案(1)|浏览(363)

我有一个mongodb_exporter的问题(prometheus metrics exporter for mongodb).我想这是因为我这边的配置问题,但经过2天的搜索,我没有解决方案:)
我在K8S上运行mongodb,并将mongodb_exporter作为边车吊舱运行。(我认为,因为没有错误),显示一些指标,但我的问题是,这只是"执行"指标(见下文),我只有一个"mongodb"指标!!=〉mongodb_up 1.即使我设置了选项"--collect-all"或"--collector. collstats"。我的"config"中没有任何"有用的"指标。数据库,如集合大小等....
连接到数据库是确定的,因为如果我改变用户名/密码/数据库端口,我运行到连接问题。我认为我的用户有正确的权利(在我的文本中更改真实密码为"密码"):

Successfully added user: {
        "user" : "exporter",
        "roles" : [
                {
                        "role" : "clusterMonitor",
                        "db" : "admin"
                },
                {
                        "role" : "read",
                        "db" : "local"
                }
        ]
}
    • 这是我的Pod配置:**
- name: metrics
          image: docker.io/bitnami/mongodb-exporter:latest
          command:
            - /bin/bash
            - '-ec'
          args:
            - >
              /bin/mongodb_exporter --web.listen-address ":9216"
              --mongodb.uri=mongodb://exporter:password@localhost:27017/config? --log.level="debug"  --collect-all
          ports:
            - name: metrics
              containerPort: 9216
              protocol: TCP
          env:
          resources:
            limits:
              cpu: 50m
              memory: 250Mi
            requests:
              cpu: 25m
              memory: 50Mi
          livenessProbe:
            httpGet:
              path: /
              port: metrics
              scheme: HTTP
            initialDelaySeconds: 15
            timeoutSeconds: 5
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /
              port: metrics
              scheme: HTTP
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
    • 日志**
  • 导出器启动日志(调试已激活):
time="2023-02-03T09:02:25Z" level=debug msg="Compatible mode: false"
time="2023-02-03T09:02:25Z" level=debug msg="Connection URI: mongodb://exporter:password@localhost:27017/config?"
level=info ts=2023-02-03T09:02:25.224Z caller=tls_config.go:195 msg="TLS is disabled." http2=false
  • 显示的度量:
# HELP collector_scrape_time_ms Time taken for scrape by collector
# TYPE collector_scrape_time_ms gauge
collector_scrape_time_ms{collector="general",exporter="mongodb"} 0
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0
go_gc_duration_seconds{quantile="0.75"} 0
go_gc_duration_seconds{quantile="1"} 0
go_gc_duration_seconds_sum 0
go_gc_duration_seconds_count 0
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 17
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.17.13"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 3.655088e+06
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 3.655088e+06
[....]
# HELP mongodb_up Whether MongoDB is up.
# TYPE mongodb_up gauge
mongodb_up 1
[...]
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 7.35940608e+08
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
    • 环境**K8S MongoDB版本:4.2.0提前感谢任何帮助:)
jc3wubiy

jc3wubiy1#

是的,在github上的JMLX42的帮助下找到了解决方案。关键是要获取另一个映像。从docker.io/bitnami/mongodb-exporter:latest更改为percona/mongodb_exporter:0.37.0(并调整配置):

- name: metrics
      image: percona/mongodb_exporter:0.37.0
      args:
        - '--mongodb.uri=mongodb://exporter:password@localhost:27017/config'
        - '--collect-all'
      ports:
        - name: metrics
          containerPort: 9216
          protocol: TCP
      resources:
        requests:
          memory: "50Mi"
          cpu: "25m"
        limits:
          memory: "250Mi"
          cpu: "50m"
      livenessProbe:
        failureThreshold: 3
        initialDelaySeconds: 15
        periodSeconds: 5
        successThreshold: 1
        timeoutSeconds: 5
        httpGet:
          path: /
          port: metrics
      readinessProbe:
        failureThreshold: 3
        initialDelaySeconds: 5
        periodSeconds: 5
        successThreshold: 1
        timeoutSeconds: 1
        httpGet:
          path: /
          port: metrics

注意:奇怪的是--collect-all不收集收集数据,我必须用--mongodb.collstats-colls指定收集列表。
例如:--mongodb.collstats-colls=config.App,config.ApplicationOverride,config.Caller,config.CommonRules,config.HabilitationOverride,config.IconSvg,config.UpdateStatusEntity,config.feature

相关问题