Skip to content

Commit d4f935f

Browse files
committed
docs: add pg_stat_monitor ecosystem component documentation
Add the pg_stat_monitor adapter doc (overview, installation, usage) to the Eco Component Adaption section, in both English and Chinese. Closes #223 Signed-off-by: jokerzsd <2701819133@qq.com>
1 parent 6068dc3 commit d4f935f

4 files changed

Lines changed: 118 additions & 0 deletions

File tree

CN/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
*** xref:5.9.adoc[pgrouting]
5353
*** xref:5.10.adoc[system_stats]
5454
*** xref:5.11.adoc[pgtt]
55+
*** xref:5.13.adoc[pg_stat_monitor]
5556
*** xref:5.14.adoc[pgnodemx]
5657
* 监控运维
5758
** xref:3.2.adoc[日常监控]

CN/modules/ROOT/pages/5.13.adoc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
:sectnums:
3+
:sectnumlevels: 5
4+
5+
= pg_stat_monitor
6+
7+
== 概述
8+
pg_stat_monitor 是 Percona 开发的 PostgreSQL 查询性能监控扩展。它在一个视图里集中收集查询文本、耗时和等待事件等统计信息。它与 IvorySQL 完全兼容。
9+
10+
== 安装
11+
12+
=== 前置条件
13+
pg_stat_monitor 需要在服务启动时加载,在 postgresql.conf 中添加:
14+
15+
[literal]
16+
----
17+
shared_preload_libraries = 'pg_stat_monitor'
18+
----
19+
20+
=== 源码安装
21+
22+
[NOTE]
23+
请确保环境中已安装 **IvorySQL {ivorysql-version} 或以上版本**,且 `pg_config` 在 PATH 中。
24+
25+
[literal]
26+
----
27+
$ git clone https://github.com/percona/pg_stat_monitor.git
28+
$ cd pg_stat_monitor
29+
$ make USE_PGXS=1
30+
$ sudo make USE_PGXS=1 install
31+
----
32+
33+
== 创建扩展并验证
34+
35+
使用 psql 连接数据库,执行以下命令:
36+
37+
[literal]
38+
----
39+
ivorysql=# CREATE EXTENSION pg_stat_monitor;
40+
CREATE EXTENSION
41+
42+
ivorysql=# SELECT * FROM pg_available_extensions WHERE name = 'pg_stat_monitor';
43+
name | default_version | installed_version | comment
44+
-----------------+-----------------+-------------------+--------------------
45+
pg_stat_monitor | 2.1 | 2.1 | pg_stat_monitor
46+
----
47+
48+
== 查询统计信息
49+
50+
启用扩展后,查询统计信息收集在 `pg_stat_monitor` 视图中:
51+
52+
[literal]
53+
----
54+
ivorysql=# SELECT bucket_start_time, query, calls, total_exec_time
55+
FROM pg_stat_monitor
56+
ORDER BY total_exec_time DESC
57+
LIMIT 5;
58+
----

EN/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
*** xref:5.9.adoc[pgrouting]
5353
*** xref:5.10.adoc[system_stats]
5454
*** xref:5.11.adoc[pgtt]
55+
*** xref:5.13.adoc[pg_stat_monitor]
5556
*** xref:5.14.adoc[pgnodemx]
5657
* Monitor and O&M
5758
** xref:3.2.adoc[Monitoring]

EN/modules/ROOT/pages/5.13.adoc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
:sectnums:
3+
:sectnumlevels: 5
4+
5+
= pg_stat_monitor
6+
7+
== Overview
8+
pg_stat_monitor is a query performance monitoring extension for PostgreSQL developed by Percona. It collects statistics in a single view, including query text, timing, and wait events. It is fully compatible with IvorySQL.
9+
10+
== Installation
11+
12+
=== Prerequisites
13+
pg_stat_monitor must be loaded at server start. Add it to `shared_preload_libraries` in `postgresql.conf`:
14+
15+
[literal]
16+
----
17+
shared_preload_libraries = 'pg_stat_monitor'
18+
----
19+
20+
=== Source Code Installation
21+
22+
[NOTE]
23+
Please ensure that **IvorySQL {ivorysql-version} or above** is installed and `pg_config` is available in `PATH`.
24+
25+
[literal]
26+
----
27+
$ git clone https://github.com/percona/pg_stat_monitor.git
28+
$ cd pg_stat_monitor
29+
$ make USE_PGXS=1
30+
$ sudo make USE_PGXS=1 install
31+
----
32+
33+
== Create Extension and Verify
34+
35+
Connect to the database with psql and execute the following commands:
36+
37+
[literal]
38+
----
39+
ivorysql=# CREATE EXTENSION pg_stat_monitor;
40+
CREATE EXTENSION
41+
42+
ivorysql=# SELECT * FROM pg_available_extensions WHERE name = 'pg_stat_monitor';
43+
name | default_version | installed_version | comment
44+
-----------------+-----------------+-------------------+--------------------
45+
pg_stat_monitor | 2.1 | 2.1 | pg_stat_monitor
46+
----
47+
48+
== Query Statistics
49+
50+
After enabling the extension, query statistics are collected in the `pg_stat_monitor` view:
51+
52+
[literal]
53+
----
54+
ivorysql=# SELECT bucket_start_time, query, calls, total_exec_time
55+
FROM pg_stat_monitor
56+
ORDER BY total_exec_time DESC
57+
LIMIT 5;
58+
----

0 commit comments

Comments
 (0)