Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article covers the mechanics that apply to all six guides: enabling the telemetry they read, opening a guide, working through it, and resolving the empty charts that come from missing data. For what each guide is for, see What are the troubleshooting guides? For chart-by-chart interpretation, see the individual guide articles.
flowchart LR
A[1 Enable telemetry] --> B[2 Open the guide]
B --> C[3 Set the time range]
C --> D[4 Clear the banners]
D --> E[5 Work the tabs in order]
E --> F[6 Apply a fix]
F --> G[7 Re-check]
G -->|Still unresolved| E
Prerequisites
Enable telemetry before you need it. Data starts accumulating only from the moment a source is turned on, so enabling it during an incident doesn't help you investigate what already happened. Treat this condition as day-one server configuration.
Two places to configure things:
- Diagnostic settings, to route log categories to a Log Analytics workspace. Follow Configure and access logs.
- Server parameters, to enable Query Store, enhanced metrics, and individual parameters. See Server parameters.
What each guide requires
| Guide | Diagnostic log categories | Query Store | Enhanced metrics | Server parameters |
|---|---|---|---|---|
| CPU | Server Logs, Sessions data, Query Store Runtime, AllMetrics | pg_qs.query_capture_mode = TOP or ALL |
metrics.collector_database_activity |
log_lock_waits for Locking and blocking |
| Memory | Server Logs, Sessions data, Query Store Runtime | pg_qs.query_capture_mode = TOP or ALL |
metrics.collector_database_activity |
None |
| IOPS | Query Store Runtime, Server Logs, Sessions data, Query Store Wait Statistics | pg_qs.query_capture_mode = TOP or ALL; pgms_wait_sampling.query_capture_mode = ALL |
metrics.collector_database_activity |
track_io_timing = ON |
| Temporary files | Sessions data, Query Store Runtime, Query Store Wait Statistics | pg_qs.query_capture_mode = TOP or ALL; pgms_wait_sampling.query_capture_mode = ALL |
metrics.collector_database_activity |
None |
| Autovacuum monitoring | Server Logs, Autovacuum and schema statistics, Remaining transactions | Not required | metrics.collector_database_activity for the enhanced metrics tab |
log_autovacuum_min_duration, non-negative |
| Autovacuum blockers | Sessions data, Remaining transactions | Not required | Not required | None |
For information about what each source contains and how much you can trust it, see Telemetry reference.
Viewing queries through native logging
Query Store is the primary source of query data on both primaries and read replicas. Native logging is an alternative view of the same queries. Use it if you want it instead of, or alongside, Query Store. It needs two parameters:
log_line_prefixset to exactlytime=%t, session=%c, pid=%p, user=%u, db=%d, client=%h, app=%aincluding the trailing space, because the guide parses these named fields out of your log lines. A different prefix, even one carrying the same information in another order, leaves the log-based charts empty.log_min_duration_statementset to a threshold in milliseconds. Don't use0.
Tip
If you only do one thing, enable all the categories in the preceding table on every production server. The guides degrade gracefully with partial data, but you can't retroactively collect data that wasn't captured during the incident you're now investigating.
Open a guide
In the Azure portal, go to your Azure Database for PostgreSQL flexible server instance.
Under Monitoring in the left menu, select Troubleshooting guides.
Select the tab for the problem you're investigating.
Set the time range you want to analyze.
Note
One hour is the minimum. A shorter selection falls back to a one-hour capture ending at your chosen end time, so expect a wider window than you asked for.
Work through a guide
Every guide follows the same rhythm. Once you complete one, the rest are familiar.
1. Clear the banners first
Banners at the top of a guide come in two kinds, and you need to tell them apart:
- Missing data warnings, for example "Enhanced metrics are currently disabled" or "Query Store is not enabled." Resolve these warnings before reading anything else. Charts fed by a disabled source render empty, which looks identical to a healthy server.
- Detected problems, for example worker saturation, long-running transactions, or excessive logging. These problems are findings. They usually point directly at the tab you should open first.
2. Confirm the symptom and the window
The first tab always shows the metric that defines the problem. Verify there's a real spike in the window you care about, and note exactly when it starts and ends. Every subsequent tab is read against that window. If you drill into queries across a four-hour range when the spike lasted fifteen minutes, the ranking is dominated by normal traffic.
3. Separate "more work" from "less efficient work"
The Workload tab exists to answer one question: did the amount of work increase? If tuple activity rises in lockstep with the resource metric, the server is doing more legitimate work, and your options are tuning the top queries or scaling. If the resource climbed while workload stayed flat, something got less efficient: bloat, a plan change, lock contention, or a configuration change.
4. Narrow to a cause
Move outward-in through the remaining tabs: sessions, then queries, then waits, checkpoints, or configuration. Grids are interactive. Select a row to expand per-query history, or to read what a wait event means and what causes it.
5. Apply a fix, then re-check
Most tabs end with recommendations split into immediate mitigations and durable fixes. Apply one change at a time, then refresh the guide and confirm the metric moved. Changing several parameters at once makes it impossible to attribute the improvement, or the regression.
When a chart is empty or the data looks wrong
An empty chart nearly always means missing telemetry, not a healthy server. Work through these in order. They're listed roughly by how often they turn out to be the answer.
| What you see | Likely cause | What to do |
|---|---|---|
| Every chart on a tab is blank | That tab's data source isn't enabled | Check the banners, then the requirements table. |
| The CPU Queries tab is blank | Query Store isn't enabled, or you're using native logging and log_line_prefix doesn't match the expected format |
Set pg_qs.query_capture_mode to TOP or ALL. If you rely on native logging, see Viewing queries through native logging. A prefix mismatch fails silently, with no banner. |
| Data exists up to a point, then stops | Ingestion lag | Allow up to 30 minutes. Widen the range and retry. |
| You just enabled something and nothing changed | Not yet applied or not yet collected | Confirm the parameter is applied. Static parameters need a restart, dynamic ones don't. Then allow up to 30 minutes. |
| Some charts work, others don't | Guides read several sources independently | The populated charts tell you which source is flowing. Compare against the requirements table to find the gap. |
| Query IDs but no SQL text | Withheld by design | See Retrieve the text of a query. |
| A numeric ID where you expected a username | Withheld by design | See Retrieve a username or role. |
| Numbers don't match the database | Guides filter, sample, and cap | Expected. See Reading the numbers accurately. |
| A short spike you know happened isn't there | Sampling gap | Session and wait data are sampled. Events shorter than the interval can leave no trace. |
| Genuinely nothing in the window | No activity | Widen the range, or use the Overview page to find when the server was actually busy. |
Important
A guide missing a data source doesn't error on every affected chart. Some simply render empty. If you haven't confirmed the source is enabled, an empty chart tells you nothing at all.
Retrieve the text of a query
For privacy, the portal shows a numeric query ID rather than SQL text. To resolve this issue:
Connect to the
azure_sysdatabase, where Query Store keeps its data.psql -h <server_name>.postgres.database.chinacloudapi.cn -U <admin_user_name> -d azure_sysLook up the identifier shown in the guide.
SELECT query_sql_text FROM query_store.query_texts_view WHERE query_text_id = <query_id>;
Note
Text in the database is subject to pg_qs.retention_period_in_days, which is typically shorter
than your Log Analytics retention. You can see a query ID in the guide whose text already
aged out of azure_sys. To keep text for as long as the statistics, enable pg_qs.emit_query_text
and route the query text category to Log Analytics.
On a read replica
Query Store is supported on read replicas, so the preceding steps work there too. Connect to azure_sys
on the replica and query query_store.query_texts_view exactly as you would on a primary.
There's a fallback for cases where that approach isn't possible, such as when you can't connect to the replica directly, or you need text for a window that already aged out of the replica's Query Store retention. In those cases, resolve text through Log Analytics instead:
- Set
pg_qs.emit_query_text=onon the replica. - In Diagnostic settings, enable the allLogs or audit category group.
- Look up the identifier in the
PGSQLQueryStoreQueryTexttable by using the KQL the guide generates.
Allow up to 30 minutes after enabling, and ensure you have at least Reader access to the workspace.
Retrieve a username or role
The portal shows a numeric role ID from pg_catalog instead of a username. Cast it to regrole to
resolve it:
SELECT <role_id>::regrole;
For example, for role ID 24776:
SELECT 24776::regrole;
You can also query pg_roles directly.