🌐 AI搜索 & 代理 主页
Skip to content

Commit 36bd11a

Browse files
cursoragentNikolayS
andcommitted
Refactor: Improve documentation and code clarity
Co-authored-by: nik <nik@postgres.ai>
1 parent 471c80a commit 36bd11a

File tree

7 files changed

+51
-54
lines changed

7 files changed

+51
-54
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ Experience the full monitoring solution: **https://demo.postgres.ai** (login: `d
5757
**Infrastructure:**
5858
- **Linux machine** with Docker installed (separate from your database server)
5959
- **Docker access** - the user running `postgres_ai` must have Docker permissions
60-
- **Access (network and pg_hba)** to the Postgres database(s) you want to monitor
60+
- **Access (network and `pg_hba.conf`)** to the Postgres database(s) you want to monitor
6161

6262
**Database:**
63-
- Supports Postgres versions 14-18
64-
- **pg_stat_statements extension must be created** for the DB used for connection
63+
- Supports Postgres 14-18
64+
- **pg_stat_statements extension must be created** for the database used for the connection
6565

66-
## ⚠️ Security Notice
66+
## ⚠️ Security notice
6767

6868
**WARNING: Security is your responsibility!**
6969

@@ -143,10 +143,10 @@ curl -o postgres_ai https://gitlab.com/postgres-ai/postgres_ai/-/raw/main/postgr
143143
&& chmod +x postgres_ai
144144
```
145145

146-
Now, start it and wait for a few minutes. To obtain a PostgresAI access token for your organization, visit https://console.postgres.ai (`Your org name → Manage → Access tokens`):
146+
Now, start it and wait for a few minutes. To obtain a PostgresAI access token for your organization, visit `https://console.postgres.ai` (`Your org name → Manage → Access tokens`):
147147

148148
```bash
149-
# Production setup with your Access token
149+
# Production setup with your access token
150150
./postgres_ai quickstart --api-key=your_access_token
151151
```
152152
**Note:** You can also add your database instance in the same command:
@@ -268,10 +268,10 @@ Technical URLs (for advanced users):
268268
### Node.js CLI (early preview)
269269

270270
```bash
271-
# run without install
271+
# Run without installing
272272
node ./cli/bin/postgres-ai.js --help
273273

274-
# local dev: install aliases into PATH
274+
# Local development: install aliases into PATH
275275
npm --prefix cli install --no-audit --no-fund
276276
npm link ./cli
277277
postgres-ai --help
@@ -305,9 +305,9 @@ Install dev dependencies (includes `pytest`, `pytest-postgresql`, `psycopg`, etc
305305
python3 -m pip install -r reporter/requirements-dev.txt
306306
```
307307

308-
### Running Tests
308+
### Running tests
309309

310-
#### Unit Tests Only (Fast, No External Services Required)
310+
#### Unit tests only (fast, no external services required)
311311

312312
Run only unit tests with mocked Prometheus interactions:
313313
```bash
@@ -320,7 +320,7 @@ pytest tests/reporter/test_generators_unit.py -v
320320
pytest tests/reporter/test_formatters.py -v
321321
```
322322

323-
#### All Tests: Unit + Integration (Requires PostgreSQL)
323+
#### All tests: unit + integration (requires PostgreSQL)
324324

325325
Run the complete test suite (both unit and integration tests):
326326
```bash
@@ -333,7 +333,7 @@ Integration tests create a temporary PostgreSQL instance automatically and requi
333333
- `pytest tests/reporter`**Unit tests only** (integration tests skipped)
334334
- `pytest tests/reporter --run-integration`**Both unit and integration tests**
335335

336-
### Test Coverage
336+
### Test coverage
337337

338338
Generate coverage report:
339339
```bash

cli/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ postgres-ai mon health [--wait <sec>] # Check monitoring services health
9696

9797
##### Quickstart options
9898
- `--demo` - Demo mode with sample database (testing only, cannot use with --api-key)
99-
- `--api-key <key>` - Postgres AI API key for automated report uploads
99+
- `--api-key <key>` - PostgresAI API key for automated report uploads
100100
- `--db-url <url>` - PostgreSQL connection URL to monitor (format: `postgresql://user:pass@host:port/db`)
101101
- `-y, --yes` - Accept all defaults and skip interactive prompts
102102

@@ -205,12 +205,12 @@ API key resolution order:
205205

206206
Base URL resolution order:
207207
- API base URL (`apiBaseUrl`):
208-
1. Command line option (`--api-base-url`)
208+
1. Command-line option (`--api-base-url`)
209209
2. Environment variable (`PGAI_API_BASE_URL`)
210210
3. User config file `baseUrl` (`~/.config/postgresai/config.json`)
211211
4. Default: `https://postgres.ai/api/general/`
212212
- UI base URL (`uiBaseUrl`):
213-
1. Command line option (`--ui-base-url`)
213+
1. Command-line option (`--ui-base-url`)
214214
2. Environment variable (`PGAI_UI_BASE_URL`)
215215
3. Default: `https://console.postgres.ai`
216216

@@ -264,5 +264,5 @@ Notes:
264264

265265
## Learn more
266266

267-
- Documentation: https://postgres.ai/docs
268-
- Issues: https://gitlab.com/postgres-ai/postgres_ai/-/issues
267+
- Documentation: `https://postgres.ai/docs`
268+
- Issues: `https://gitlab.com/postgres-ai/postgres_ai/-/issues`

docs/brew-installation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Homebrew Installation for PostgresAI CLI
1+
# Homebrew installation for PostgresAI CLI
22

33
This document describes how to set up and distribute the PostgresAI CLI via Homebrew.
44

5-
## For Users
5+
## For users
66

77
### Installation
88

@@ -33,9 +33,9 @@ brew uninstall postgresai
3333
brew untap postgres-ai/tap
3434
```
3535

36-
## For Maintainers
36+
## For maintainers
3737

38-
### Creating the Homebrew Tap Repository
38+
### Creating the Homebrew tap repository
3939

4040
1. Create a new GitLab repository named `homebrew-tap` at:
4141
`https://gitlab.com/postgres-ai/homebrew-tap`
@@ -53,7 +53,7 @@ brew untap postgres-ai/tap
5353
# Update the sha256 field in the formula
5454
```
5555

56-
### Updating the Formula
56+
### Updating the formula
5757

5858
After publishing a new version to npm:
5959

@@ -66,7 +66,7 @@ After publishing a new version to npm:
6666
```
6767
4. Commit and push to the homebrew-tap repository
6868

69-
### Testing Locally
69+
### Testing locally
7070

7171
Before pushing to the tap:
7272

postgres_ai_helm/INSTALLATION_GUIDE.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Postgres AI monitoring - Helm chart installation guide
1+
# PostgresAI monitoring: Helm chart installation guide
22

33
## Installation
44

@@ -70,14 +70,14 @@ kubectl create secret generic postgres-ai-monitoring-secrets \
7070

7171
**Notes:**
7272

73-
- `SINK_POSTGRES_PASSWORD` should be generated by you and will be used to connect to the internal database for storing metrics
74-
- `GRAFANA_PASSWORD` should be generated by you and will be used to access grafana
75-
- `POSTGRES_AI_API_KEY` should be attained from PostgresAI platform and will be used to connect to the PostgresAI platform
73+
- `SINK_POSTGRES_PASSWORD` should be generated by you and will be used to connect to the internal database for storing metrics.
74+
- `GRAFANA_PASSWORD` should be generated by you and will be used to access Grafana.
75+
- `POSTGRES_AI_API_KEY` should be obtained from the PostgresAI platform and will be used to connect to the PostgresAI platform.
7676
- Add `--from-literal` for each database that you want to monitor
7777
- Key must match `passwordSecretKey` in custom-values.yaml
7878
- Key name must be `db-password-<passwordSecretKey>` and value must be the password for monitoring user in the database
7979

80-
### 5. Install helm chart
80+
### 5. Install Helm chart
8181

8282
```bash
8383
helm install postgres-ai-monitoring ./postgres-ai-monitoring-0.12.tgz \
@@ -91,7 +91,7 @@ helm install postgres-ai-monitoring ./postgres-ai-monitoring-0.12.tgz \
9191
kubectl get pods -n postgres-ai-mon
9292
```
9393

94-
## Access grafana
94+
## Access Grafana
9595

9696
**Port Forward** (quick access):
9797

@@ -101,7 +101,7 @@ kubectl port-forward -n postgres-ai-mon svc/postgres-ai-monitoring-grafana 3000:
101101

102102
Open: `http://localhost:3000`
103103

104-
**Ingress**: Access via configured domain (e.g., `http://monitoring.example.com`)
104+
**Ingress**: Access via the configured domain (e.g., `http://monitoring.example.com`)
105105

106106
**Login**: Username and password from the secret (`grafana-admin-user` / `grafana-admin-password`)
107107

terraform/aws/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ On first boot, EC2 instance clones the specified version of this repository and
1717

1818
## Quick start
1919

20-
See [QUICKSTART.md](QUICKSTART.md) for step-by-step guide.
20+
See [QUICKSTART.md](QUICKSTART.md) for a step-by-step guide.
2121

2222
### Validation
2323

tests/lock_waits/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Lock Waits Metric Testing
1+
# Lock waits metric testing
22

33
This directory contains tests and scripts to verify that the `lock_waits` metric is working correctly.
44

@@ -12,17 +12,17 @@ The `lock_waits` metric collects detailed information about lock waits in Postgr
1212
- Query IDs (PostgreSQL 14+)
1313
- Wait durations and blocker transaction durations
1414

15-
## Test Components
15+
## Test components
1616

17-
### 1. Python Test Script (`test_lock_waits_metric.py`)
17+
### 1. Python test script (`test_lock_waits_metric.py`)
1818

1919
Automated test that:
2020
- Creates lock contention scenarios in the target database
2121
- Waits for pgwatch to collect metrics
2222
- Verifies the metric is collected in Prometheus/VictoriaMetrics
2323
- Validates the metric structure and labels
2424

25-
### 2. SQL Script (`create_lock_contention.sql`)
25+
### 2. SQL script (`create_lock_contention.sql`)
2626

2727
Manual SQL script to create lock contention for testing. Can be run in multiple psql sessions.
2828

@@ -42,7 +42,7 @@ Manual SQL script to create lock contention for testing. Can be run in multiple
4242
- Check `config/pgwatch-prometheus/metrics.yml` includes `lock_waits`
4343
- Verify pgwatch is collecting metrics from the target database
4444

45-
## Running the Automated Test
45+
## Running the automated test
4646

4747
### Basic Usage
4848

@@ -116,7 +116,7 @@ pgwatch_lock_waits_blocker_tx_ms{datname="target_database"}
116116

117117
## Expected Results
118118

119-
### Successful Test Output
119+
### Successful test output
120120

121121
```
122122
Setting up test environment...
@@ -144,7 +144,7 @@ Validating metric structure...
144144

145145
## Troubleshooting
146146

147-
### No Records Found
147+
### No records found
148148

149149
- **Check pgwatch is running**: `docker ps | grep pgwatch-prometheus`
150150
- **Check pgwatch logs**: `docker logs pgwatch-prometheus`
@@ -154,7 +154,7 @@ Validating metric structure...
154154
- **Check database name**: Ensure `--test-dbname` matches the monitored database
155155
- **Verify metrics exist**: `curl "http://localhost:59090/api/v1/label/__name__/values" | grep lock_waits`
156156

157-
### Invalid Data Structure
157+
### Invalid data structure
158158

159159
- **Check PostgreSQL version**: Metric requires PostgreSQL 14+ for query_id support
160160
- **Verify metric SQL**: Check the SQL query in `metrics.yml` is correct
@@ -189,9 +189,9 @@ test_lock_waits:
189189
- main
190190
```
191191
192-
## Additional Test Scenarios
192+
## Additional test scenarios
193193
194-
### Test Different Lock Types
194+
### Test different lock types
195195
196196
Modify the test to create different types of locks:
197197
@@ -203,7 +203,7 @@ LOCK TABLE lock_test_table IN EXCLUSIVE MODE;
203203
SELECT pg_advisory_lock(12345);
204204
```
205205

206-
### Test Multiple Concurrent Waits
206+
### Test multiple concurrent waits
207207

208208
Create multiple waiting transactions to test the LIMIT clause:
209209

workload_examples/single_index_analysis.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
## workload example for single index analysis dashboard
1+
## Workload example for single index analysis dashboard
22

33
This example prepares and runs a repeatable workload designed for the postgres_ai monitoring “Single index analysis” dashboard. It also shows how to deploy `pg_index_pilot`, generate controlled index bloat, and let `pg_index_pilot` automatically rebuild indexes when bloat exceeds the configured threshold during periodic runs.
44

5-
### prerequisites
5+
### Prerequisites
66

7-
- Postgres instance
7+
- PostgreSQL instance
88
- `pg_cron` extension available for scheduling periodic execution
99
- `pgbench` installed for workload generation
1010

11-
## prepare the dataset in the target database
11+
## Prepare the dataset in the target database
1212

13-
Create a table with several indexes and populate 10 million rows in the target database (e.g., `workloaddb`). This schema uses `test_pilot` schema and `items` table.
13+
Create a table with several indexes and populate 10 million rows in the target database (e.g., `workloaddb`). This schema uses the `test_pilot` schema and the `items` table.
1414

1515
```bash
1616
psql -U postgres -d workloaddb <<'SQL'
@@ -54,7 +54,7 @@ select setval('test_pilot.items_id_seq', (select coalesce(max(id),0) from test_p
5454
SQL
5555
```
5656

57-
### deploy pg_index_pilot
57+
### Deploy pg_index_pilot
5858

5959
```bash
6060
# Clone the repository
@@ -74,7 +74,7 @@ psql -U postgres -d index_pilot_control -f index_pilot_functions.sql
7474
psql -U postgres -d index_pilot_control -f index_pilot_fdw.sql
7575
```
7676

77-
### register the target database via FDW
77+
### Register the target database via FDW
7878

7979
Replace placeholders with actual connection details for your target database (the database where workload and indexes live; in examples below it is `workloaddb`).
8080

@@ -114,14 +114,11 @@ select cron.schedule_in_database(
114114
'call index_pilot.periodic(real_run := true);',
115115
'index_pilot_control' -- run in control database
116116
);
117-
SQL
118117
```
119118

120119
Behavior: when `index_pilot.periodic(true)` runs, it evaluates index bloat in the registered target database(s). If bloat for an index exceeds the configured `index_rebuild_scale_factor` at the time of a run, an index rebuild is initiated.
121120

122-
#
123-
124-
### run the workload with pgbench
121+
### Run the workload with pgbench
125122

126123
Use two concurrent pgbench jobs: one generates updates that touch ranges of `id` and another performs point-lookups by `id`. This mix creates index bloat over time; when bloat exceeds the configured threshold during a periodic run, `pg_index_pilot` triggers a rebuild.
127124

@@ -164,7 +161,7 @@ tmux new -d -s pgbench_selects 'env PGPASSWORD=<password> pgbench -n -h 127.0.0.
164161

165162
Let these processes run continuously. The updates will steadily create index bloat; every 20 minutes, `index_pilot.periodic(true)` evaluates bloat and, if thresholds are exceeded, initiates index rebuilds.
166163

167-
### monitor results
164+
### Monitor results
168165

169166
- In the postgres_ai monitoring included with this repository, use:
170167
- `Single index analysis` for targeted inspection

0 commit comments

Comments
 (0)