问题描述
我已修复此文件并运行 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
主机名。