Prometheus无法将数据写入PostgreSQL

问题描述

我已修复此文件并运行 https://github.com/timescale/prometheus-postgresql-adapter/blob/master/docker-compose.yml

服务正常启动,但随后我收到错误消息:

prometheus_1 | ts = 2020-08-27T12:55:50.967Z 呼叫者= dedupe.go:112组件=远程级别=警告remote_name = 686501 url = http:// prometheus_postgresql_adapter:9201 / write msg =“失败 发送批次,重试” err =“发布 “ http:// prometheus_postgresql_adapter:9201 / write”:拨打tcp:查找 127.0.0.11:53上的prometheus_postgresql_adapter:没有这样的主机”

如何解决?

有我的prometheus.yml

global:  
  scrape_interval:     10s  
  evaluation_interval: 10s

scrape_configs:
 - job_name: prometheus    
   static_configs:
     - targets: ['node_exporter:9100']

remote_write:
  - url: "http://prometheus_postgresql_adapter:9201/write" 
remote_read:
  - url: "http://prometheus_postgresql_adapter:9201/read"

解决方法

在docker-compose文件的服务名称中使用下划线会引起麻烦(下划线不是主机名的有效字符)。

尝试将docker-compose文件中的服务名称更改为prometheus-postgresql-adapter

services:

...

  prometheus-postgresql-adapter:
    build:
      context: .
      ...

,然后将prometheus.yml配置文件更改为:

remote_write:
  - url: "http://prometheus-postgresql-adapter:9201/write" 
remote_read:
  - url: "http://prometheus-postgresql-adapter:9201/read"

使用正确的prometheus-postgresql-adapter主机名。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...