Prometheus PostgreSQL服务器导出程序示例在MacOS上不起作用? [英] Prometheus PostgreSQL server exporter example not working on MacOS?

查看:136
本文介绍了Prometheus PostgreSQL服务器导出程序示例在MacOS上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 https://github.com/wrouesnel/postgres_exporter上尝试快速入门示例在MacOS主机设备上。在一个终端中,我在主机网络上以交互模式运行了 postgres 图像:

I'd like to try out the quick start example at https://github.com/wrouesnel/postgres_exporter on a MacOS host device. In one terminal, I run a postgres image in interactive mode on the host network:

> docker run --network=host -it --rm --env POSTGRES_PASSWORD=password postgres
Unable to find image 'postgres:latest' locally
latest: Pulling from library/postgres
8f91359f1fff: Pull complete 
c6115f5efcde: Pull complete 
28a9c19d8188: Pull complete 
2da4beb7be31: Pull complete 
fb9ca792da89: Pull complete 
cedc20991511: Pull complete 
b866c2f2559e: Pull complete 
5d459cf6645c: Pull complete 
cf66247ad881: Pull complete 
35e29440d9da: Pull complete 
362779251360: Pull complete 
fb82d778d08d: Pull complete 
b1f8d21ff25d: Pull complete 
6d49eb0e8dd0: Pull complete 
Digest: sha256:be456a40361cd836e0e1b35fc4d872e20e138f214c93138425169c4a2dfe1b0e
Status: Downloaded newer image for postgres:latest
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Etc/UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2019-10-03 19:06:10.222 UTC [42] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-10-03 19:06:10.235 UTC [43] LOG:  database system was shut down at 2019-10-03 19:06:10 UTC
2019-10-03 19:06:10.239 UTC [42] LOG:  database system is ready to accept connections
 done
server started

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

waiting for server to shut down....2019-10-03 19:06:10.320 UTC [42] LOG:  received fast shutdown request
2019-10-03 19:06:10.322 UTC [42] LOG:  aborting any active transactions
2019-10-03 19:06:10.325 UTC [42] LOG:  background worker "logical replication launcher" (PID 49) exited with exit code 1
2019-10-03 19:06:10.325 UTC [44] LOG:  shutting down
2019-10-03 19:06:10.338 UTC [42] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2019-10-03 19:06:10.436 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2019-10-03 19:06:10.438 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2019-10-03 19:06:10.440 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-10-03 19:06:10.450 UTC [51] LOG:  database system was shut down at 2019-10-03 19:06:10 UTC
2019-10-03 19:06:10.453 UTC [1] LOG:  database system is ready to accept connections

在另一个终端中,我运行 postgres_exporter 并将其连接到该数据库:

while in another terminal, I run postgres_exporter and connect it to that database:

> docker run --net=host --env DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=disable" wrouesnel/postgres_exporter
Unable to find image 'wrouesnel/postgres_exporter:latest' locally
latest: Pulling from wrouesnel/postgres_exporter
0d6d2d2516f9: Pull complete 
e9d7b571ef5e: Pull complete 
Digest: sha256:aeea975f0efeacb49c170f0f7c4a4000d3f0099cc33437aedd3f276e628cde1c
Status: Downloaded newer image for wrouesnel/postgres_exporter:latest
time="2019-10-03T19:09:20Z" level=info msg="Established new database connection to \"localhost:5432\"." source="postgres_exporter.go:778"
time="2019-10-03T19:09:20Z" level=info msg="Semantic Version Changed on \"localhost:5432\": 0.0.0 -> 11.5.0" source="postgres_exporter.go:1238"
time="2019-10-03T19:09:20Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1459"

据我了解,我应该可以转到我的浏览器中的localhost:9187 ,然后查看导出的指标。但是,我得到的是连接被拒绝:

As I understand it, I should be able to go to localhost:9187 in my browser and see the exported metrics. What I get, however, is that the connection gets refused:

> curl http://localhost:9187
curl: (7) Failed to connect to localhost port 9187: Connection refused

我怀疑这是因为,如 https:// docs所述.docker.com / network / host /


主机网络驱动程序仅适用于Linux主机,不受支持在Mac的Docker桌面,Windows的Docker桌面或Windows Server的Docker EE上。

The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

这是引起问题的原因,如果那么,我如何才能适应这个快速入门示例,以便在Mac上使用Docker Desktop来工作?

Is this what is causing the issue and if so, how can I adapt this quickstart example to work using Docker Desktop for Mac?

推荐答案

有点晚了,但也许适合某人在将来。我在Windows的Docker桌面上遇到了同样的问题。为此,我使用了以下命令:

A little late, but maybe for someone in the future. I had the same problem on Docker Desktop for Windows. For it to work I used the following command:

docker run -p 9187:9187 -e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=disable" wrouesnel/postgres_exporter

这篇关于Prometheus PostgreSQL服务器导出程序示例在MacOS上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆