openGauss Prometheus exporter
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 2 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 7 个月前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 |
openGauss 服务器导出器
用于导出 openGauss 服务器度量的 Prometheus 导出器。
快速开始
该软件包适用于 Docker:
# Start an example database
docker run --net=host -it --rm -e GS_PASSWORD=mtkOP@128 enmotech/opengauss
# Connect to it
docker run --net=host -e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=disable" enmotech/opengauss_exporter
编译与运行
Gitee
默认的 Makefile 行为是编译生成二进制文件:
git clone https://gitee.com/opengauss/openGauss-prometheus-exporter.git
cd openGauss-prometheus-exporter
make build
export DATA_SOURCE_NAME="postgresql://login:password@hostname:port/dbname"
./bin/opengauss_exporter <flags>
构建Docker,请运行make docker命令。
本地连接(套接字)
运行的用户的名称必须与数据库操作用户一致。
查询套接字文件。
postgres=# show unix_socket_directory;
unix_socket_directory
-----------------------
/tmp
(1 row)
设置环境变量
export PGHOST=/tmp
export PGPORT=26000
export PGUSER=omm
export PGDBNAME=postgres
or
export DATA_SOURCE_NAME="host=/tmp port=26000 user=omm dbname=postgres"
标志
-
help显示上下文相关的帮助(也可以尝试 --help-long 和 --help-man)。 -
web.listen-address用于 web 界面和遥测的监听地址。默认为:9187。 -
web.telemetry-path用于公开指标的路径。默认为/metrics。 -
disable-settings-metrics如果您不想收集pg_settings,请使用此标志。 -
auto-discover-databases是否动态发现服务器上的数据库。 -
config包含要运行的查询的 YAML 文件的路径。查看og_exporter.yaml了解格式的示例。 -
--dry-run不运行 - 打印指标映射的内部表示。在调试自定义查询文件时很有用。 -
constantLabels在所有指标中设置的标签。用逗号分隔的label=value对列表。 -
version显示应用程序版本。 -
exclude-databases当启用 autoDiscoverDatabases 时,要移除的数据库列表。 -
log.level设置日志级别:debug、info、warn、error、fatal中的一个。 -
log.format设置日志输出目标和格式。例如logger:syslog?appname=bob&local=7或logger:stdout?json=true默认为logger:stderr。
环境变量
以下环境变量配置导出器:
-
OG_EXPORTER_URLPG_EXPORTER_URLDATA_SOURCE_NAME默认的旧格式。接受 URI 形式和 key=value 形式的参数。URI 可能包含用于连接的用户名和密码。 -
OG_EXPORTER_WEB_LISTEN_ADDRESS用于 web 界面和遥测的监听地址。默认为:9187。 -
OG_EXPORTER_WEB_TELEMETRY_PATH用于公开指标的路径。默认为/metrics。 -
OG_EXPORTER_DISABLE_SETTINGS_METRICS如果您不想收集pg_settings,请使用此标志。值可以是true或false。默认为false。 -
OG_EXPORTER_AUTO_DISCOVER_DATABASES是否动态发现服务器上的数据库。值可以是true或false。默认为false。 -
OG_EXPORTER_CONSTANT_LABELS在所有指标中设置的标签。用逗号分隔的label=value对列表。 -
OG_EXPORTER_EXCLUDE_DATABASES当启用 autoDiscoverDatabases 时,要移除的数据库列表。默认为空字符串。
以 OG_ 开头的环境变量设置的设置将被相应的 CLI 标志覆盖。
设置 openGauss 服务器的数据源名称
openGauss 服务器的 数据源名称
必须通过 OG_EXPORTER_URL 或 PG_EXPORTER_URL 或 DATA_SOURCE_NAME 环境变量设置。
优先级顺序如下
OG_EXPORTER_URL > PG_EXPORTER_URL > DATA_SOURCE_NAME
对于在默认的 Debian/Ubuntu 安装上本地运行,以下命令有效(根据需要转换为初始化脚本):
DATA_SOURCE_NAME="user=postgres host=/var/run/postgresql/ sslmode=disable" opengauss_exporter
此外,您还可以设置一个源列表,以便从单个导出器设置中抓取不同的实例。只需定义一个逗号分隔的字符串。
DATA_SOURCE_NAME="port=5432,port=6432" opengauss_exporter
查看 github.com/lib/pq 模块了解格式连接字符串的其他方法。
如果您为多个数据库定义连接字符串,则需要数据库版本一致性 export DATA_SOURCE_NAME=postgresql://gaussdb:password@127.0.0.1:26000/postgres?sslmode=disable,postgresql://gaussdb:password@127.0.0.1:26001/postgres?sslmode=disable
通过配置文件添加新的指标
--config 命令行参数指定一个包含要运行的额外查询的 YAML 文件。一些示例在 og_exporter.yaml 中提供。
自动发现数据库
要从一个数据库服务器上的所有数据库中抓取指标,可以通过 --auto-discover-databases 标志动态发现数据库 DSN。当为 true 时,对于所有配置的 DSN 运行 SELECT datname FROM pg_database WHERE datallowconn = true AND datistemplate = false and datname != current_database()。从结果中创建一组新的 DSN,用于抓取指标。
另外,--exclude-databases 选项允许过滤自动发现的结果,丢弃您不需要的数据库。
运行测试
make build
cd test;sh test.sh ../bin/opengauss_exporter <config_file>
OpenGauss
监控用户
CREATE USER dbuser_monitor with login monadmin PASSWORD 'Mon@1234';
grant usage on schema dbe_perf to dbuser_monitor;
grant select on pg_stat_replication to dbuser_monitor;
主要与备用
docker network create opengauss_network --subnet=172.11.0.0/24
docker run --network opengauss_network --ip 172.11.0.101 \
--privileged=true --name opengauss_primary -h opengauss_primary -p 1111:5432 -d \
-e GS_PORT=5432 -e OG_SUBNET=172.11.0.0/24 -e GS_PASSWORD=Gauss@123 -e NODE_NAME=opengauss_primary \
-e 'REPL_CONN_INFO=replconninfo1 = '\''localhost=172.11.0.101 localport=5434 localservice=5432 remotehost=172.11.0.102 remoteport=5434 remoteservice=5432'\''\n' enmotech/opengauss:1.1.0 -M primary
docker run --network opengauss_network --ip 172.11.0.102 \
--privileged=true --name opengauss_standby1 -h opengauss_standby1 -p 1112:5432 -d \
-e GS_PORT=5432 -e OG_SUBNET=172.11.0.0/24 -e GS_PASSWORD=Gauss@123 -e NODE_NAME=opengauss_standby1 \
-e 'REPL_CONN_INFO=replconninfo1 = '\''localhost=172.11.0.102 localport=5434 localservice=5432 remotehost=172.11.0.101 remoteport=5434 remoteservice=5432'\''\n' enmotech/opengauss:1.1.0 -M standby
请提供需要翻译的原始文本内容,我将会按照您的要求进行翻译。