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

配置Prometheus远程读写后CnosDB无新表,数据未存储问题咨询

解决Prometheus远程写CnosDB 2.0.1无数据问题及Grafana展示配置

一、排查Prometheus远程写配置正确性

  1. 确认remote_write端点与认证信息
    CnosDB 2.0.1的Prometheus远程写端点为http://<cnosdb-host>:8902/api/v1/prom/write,需确保Prometheus配置文件中包含正确的认证与端点:
    remote_write:
      - url: "http://cnosdb:8902/api/v1/prom/write"
        basic_auth:
          username: "root"
          password: ""  # CnosDB默认root密码为空
        write_relabel_configs:
          - source_labels: [__name__]
            action: keep
            regex: .+  # 确保所有指标都被写入
    
  2. 检查Prometheus日志
    启动Prometheus时开启debug日志,查看远程写相关错误:
    prometheus --config.file=prometheus.yml --log.level=debug
    
    重点关注包含remote_write的日志行,排查连接失败、认证错误或数据格式问题。

二、验证CnosDB的Prometheus兼容配置

  1. 确认Docker端口映射
    启动CnosDB容器时需映射8902端口(Prometheus远程读写端口):
    docker run -d -p 8901:8901 -p 8902:8902 cnosdb/cnosdb:2.0.1
    
  2. 检查CnosDB内部Prometheus配置
    进入容器查看cnosdb.toml中[prometheus]模块是否开启:
    docker exec -it <cnosdb-container-id> cat /etc/cnosdb/cnosdb.toml | grep -A5 prometheus
    
    确保配置为:
    [prometheus]
    enable = true
    port = 8902
    

三、手动测试远程写连通性

用curl模拟Prometheus发送测试数据:

curl -X POST http://<cnosdb-host>:8902/api/v1/prom/write -u root: --data-raw 'test_prom_metric{env="dev"} 456'

登录CnosDB CLI验证数据是否生成:

docker exec -it <cnosdb-container-id> cnosdb-cli

执行查询命令:

SHOW TABLES;
SELECT * FROM test_prom_metric LIMIT 10;

若能看到对应表与数据,说明远程写通道正常。

四、排查Capture Job影响

若配置了Capture Job,需确保其remote_write配置与主远程写一致,避免分流或配置错误导致数据未写入CnosDB。检查Capture Job的输出配置,确认目标端点为CnosDB的Prometheus写接口。

五、Grafana配置CnosDB数据源展示数据

  1. 在Grafana中添加数据源,选择Prometheus类型
  2. 设置URL为http://<cnosdb-host>:8902/api/v1/prom/read
  3. 开启Basic Auth,用户名填root,密码留空
  4. 保存并测试数据源,成功后即可在Grafana面板中查询CnosDB存储的监控数据

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 20:37:24