-
Notifications
You must be signed in to change notification settings - Fork 5
docs: add query exporter monitoring documentation #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,164 @@ | ||||||||||||
| --- | ||||||||||||
| sidebar_position: 18 | ||||||||||||
| --- | ||||||||||||
|
|
||||||||||||
| # Query Exporter | ||||||||||||
|
|
||||||||||||
| The query-exporter service monitors the OpenRemote PostgreSQL database and exposes metrics on port 9560 for Prometheus scraping. It uses [query-exporter](https://github.com/albertodonato/query-exporter) to collect database health metrics. | ||||||||||||
|
|
||||||||||||
| ## Available Metrics | ||||||||||||
|
|
||||||||||||
| ### Table and Index Bloat | ||||||||||||
| - `pg_table_bloat_count` - Number of tables/indexes with bloat exceeding thresholds | ||||||||||||
| - `pg_table_bloat_ratio` - Bloat ratio per table/index (1.0 = no bloat, 2.0 = 100% bloat) | ||||||||||||
| - `pg_table_bloat_bytes` - Estimated bloat size in bytes per table/index | ||||||||||||
| - `pg_table_bloat_wasted_mb` - Estimated wasted space in megabytes per table/index | ||||||||||||
|
|
||||||||||||
| ### Autovacuum Workers | ||||||||||||
| - `pg_autovacuum_workers_active` - Number of currently active autovacuum workers | ||||||||||||
| - `pg_autovacuum_workers_max` - Maximum number of autovacuum workers configured | ||||||||||||
| - `pg_autovacuum_running` - Running autovacuum processes (labels: database, table_schema, table_name, phase) | ||||||||||||
|
|
||||||||||||
| ### Datapoint Query Performance | ||||||||||||
| - `pg_datapoint_query_duration_seconds` - Histogram of execution times for the attribute with most datapoints | ||||||||||||
| - `pg_datapoint_count` - Total number of datapoints for the top attribute | ||||||||||||
|
|
||||||||||||
| ### Database Health | ||||||||||||
| - `pg_database_size_megabytes` - Total database size in megabytes | ||||||||||||
| - `pg_connections_active` - Number of active connections | ||||||||||||
| - `pg_connections_idle` - Number of idle connections | ||||||||||||
| - `pg_locks_count` - Number of locks by type | ||||||||||||
|
|
||||||||||||
| ## Configuration | ||||||||||||
|
|
||||||||||||
| ### Environment Variables | ||||||||||||
| The service uses the following environment variables (automatically configured in `profile/deploy.yml`): | ||||||||||||
|
|
||||||||||||
| **Database Connection:** | ||||||||||||
| - `POSTGRES_HOST` - Database host (default: `postgresql`) | ||||||||||||
| - `POSTGRES_PORT` - Database port (default: `5432`) | ||||||||||||
| - `POSTGRES_DB` - Database name (default: `openremote`) | ||||||||||||
| - `POSTGRES_USER` - Database user (default: `postgres`) | ||||||||||||
| - `POSTGRES_PASSWORD` - Database password (default: `postgres`) | ||||||||||||
|
|
||||||||||||
| **Bloat Thresholds:** | ||||||||||||
| - `TABLE_BLOAT_THRESHOLD` - Table bloat ratio threshold (default: `1.2` = 20% bloat) | ||||||||||||
| - `INDEX_BLOAT_THRESHOLD` - Index bloat ratio threshold (default: `1.5` = 50% bloat) | ||||||||||||
|
|
||||||||||||
| :::note | ||||||||||||
|
|
||||||||||||
| Indexes typically bloat faster than tables, so the default index threshold is higher. | ||||||||||||
|
|
||||||||||||
| ::: | ||||||||||||
|
|
||||||||||||
| ### Customize Thresholds | ||||||||||||
| Set environment variables before starting services: | ||||||||||||
| ```bash | ||||||||||||
| export TABLE_BLOAT_THRESHOLD=1.3 # 30% table bloat | ||||||||||||
| export INDEX_BLOAT_THRESHOLD=2.0 # 100% index bloat | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ### Query Intervals | ||||||||||||
| - Table bloat queries: Every 5 minutes | ||||||||||||
| - Autovacuum queries: Every 30 seconds | ||||||||||||
| - Datapoint performance: Every 60 seconds | ||||||||||||
| - Database size: Every 5 minutes | ||||||||||||
| - Connection/lock stats: Every 30 seconds | ||||||||||||
|
|
||||||||||||
| ## Accessing Metrics | ||||||||||||
|
|
||||||||||||
| ### View Metrics Endpoint | ||||||||||||
| ```bash | ||||||||||||
| curl http://localhost:9560/metrics | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ### Expose on Private Network | ||||||||||||
| To expose on a private network in production, uncomment this line in `profile/deploy.yml`: | ||||||||||||
| ```yaml | ||||||||||||
| - "${PRIVATE_IP:-127.0.0.1}:9560:9560" | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ## Prometheus Integration | ||||||||||||
|
|
||||||||||||
| Add this scrape configuration to your Prometheus config: | ||||||||||||
|
|
||||||||||||
| ```yaml | ||||||||||||
| scrape_configs: | ||||||||||||
| - job_name: 'openremote-postgres' | ||||||||||||
| static_configs: | ||||||||||||
| - targets: ['localhost:9560'] | ||||||||||||
|
||||||||||||
| scrape_interval: 30s | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ## Customizing Queries | ||||||||||||
|
|
||||||||||||
| To modify queries or add new metrics: | ||||||||||||
|
|
||||||||||||
| 1. Edit the `config.yaml` file located in the `query-exporter` configuration directory (by default, this is `/deployment/query-exporter/config.yaml` which is mounted as a Docker volume at the container's `/config/config.yaml` path—see your `profile/deploy.yml` for the exact path). | ||||||||||||
|
||||||||||||
| 1. Edit the `config.yaml` file located in the `query-exporter` configuration directory (by default, this is `/deployment/query-exporter/config.yaml` which is mounted as a Docker volume at the container's `/config/config.yaml` path—see your `profile/deploy.yml` for the exact path). | |
| 1. Edit the `config.yaml` file in the `query-exporter` configuration directory. | |
| - Default host path: `/deployment/query-exporter/config.yaml` | |
| - Container path (Docker volume mount): `/config/config.yaml` | |
| - For the exact host path in your environment, see the `query-exporter` volume mapping in `profile/deploy.yml`. |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sample size value mentioned here (100) should be documented in the "Query Intervals" section above for consistency. Currently, the query intervals section (lines 61-66) documents time intervals but doesn't mention sample sizes. Consider adding a note about the sample size to that section or creating a "Query Parameters" subsection.
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line states "100 most recent datapoints" but line 129 refers to "sample size (default: 100)". These should use consistent terminology - either both refer to it as a "sample" or both as "most recent datapoints". Using "sample size" is more technically accurate since it's a configurable parameter.
| - Datapoint performance samples 100 most recent datapoints from the largest attribute | |
| - Datapoint performance uses a sample size of 100 recent datapoints from the largest attribute (configurable) |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tuple header size of 23 bytes is documented as specific to "PostgreSQL 14+ (Linux)" but the documentation doesn't specify which PostgreSQL version OpenRemote uses or whether this value might differ on other platforms. Consider adding a note about verifying compatibility if users are running different PostgreSQL versions or operating systems.
| - `23` - Tuple header size for PostgreSQL 14+ (Linux) | |
| - `23` - Typical tuple header size for PostgreSQL 14+ on Linux (this value may differ for other PostgreSQL versions or operating systems; verify for your deployment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "Datapoint Query Performance" section mentions "the attribute with most datapoints" and "the top attribute", but it's unclear whether this is determined dynamically or requires configuration. Consider clarifying that this automatically identifies and monitors the attribute with the highest datapoint count.