You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Kubernetes集群中启用InfluxDB的/metrics端点

解决InfluxDB metrics端点禁用问题

先确认InfluxDB版本

InfluxDB 1.x和2.x的metrics启用逻辑完全不同,先明确你的实例版本再对应操作。

针对InfluxDB 1.x

  1. 修改配置文件influxdb.conf,找到[http]区块,开启Prometheus相关配置:
    [http]
      enabled = true
      bind-address = ":8086"
      prometheus-enabled = true
      prometheus-adapter-enabled = true
    
    如果集群里用ConfigMap挂载配置,更新ConfigMap后重启Pod即可;也可以直接在Deployment里用环境变量配置:
    env:
      - name: INFLUXDB_HTTP_PROMETHEUS_ENABLED
        value: "true"
      - name: INFLUXDB_HTTP_PROMETHEUS_ADAPTER_ENABLED
        value: "true"
    
  2. 重启InfluxDB Pod后,重新访问/metrics端点即可。

针对InfluxDB 2.x

  1. 2.x版本默认关闭metrics,需要通过启动参数或配置文件开启:
    • 用启动参数:在Deployment的容器命令中添加--metrics-disabled=false,示例:
      containers:
        - name: influxdb
          image: influxdb:2.x
          command:
            - influxd
            - --metrics-disabled=false
            - --http-bind-address=:8086
      
    • 用配置文件config.yml:
      http:
        bind-address: ":8086"
      metrics:
        disabled: false
      
  2. 如果你的InfluxDB开启了认证,Prometheus抓取时需要携带Token,在Prometheus的scrape配置里添加上header:
    scrape_configs:
      - job_name: 'influxdb'
        static_configs:
          - targets: ['my-influx:8086']
        headers:
          Authorization: 'Token 你的InfluxDB访问Token'
    
  3. 重启Pod后验证配置是否生效。

验证配置

执行以下命令测试端点是否正常返回指标:

curl my-influx:8086/metrics

内容的提问来源于stack exchange,提问作者Will

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 18:01:27