Slow-operation logs¶
This guide shows how to turn on the slow-operation log of your databases and send it to QubeSight, so that statement durations and row counts that audit logs do not carry are filled in reports.
Community Enterprise
The setting itself is in both editions. The Azure and AWS variants arrive over Event Hub, CloudWatch Logs or Kinesis, which require Enterprise.
What it does¶
Audit logs do not carry the duration, returned rows and affected rows everywhere. PostgreSQL and MySQL audit logs do not; SQL Server, Azure SQL, Cosmos DB and Aurora MySQL activity streams do. If you turn on the slow-operation log in the database and send it to QubeSight, each measurement is linked to the SQL event of the same session and server around the same time:
- Empty response time, returned rows and affected rows in reports and in the row inspector are filled and marked with a "derived" badge.
- Dashboards → Slow queries lists the slowest SQL patterns. Literal values are always replaced by
?; values such as national ids or card numbers are never shown. - The measurements are stored in a separate table. Event rows, the integrity proof and dashboard counts do not change.
Supported kinds¶
| Kind (UI name) | Reads | Platforms |
|---|---|---|
| PostgreSQL duration lines | log_min_duration_statement / log_duration lines: the statement duration |
Azure flexible server (Event Hub), Amazon RDS (CloudWatch Logs or Kinesis) |
| MySQL / MariaDB slow query log | Query_time, Lock_time, Rows_sent, Rows_examined |
Azure flexible server (Event Hub), Amazon RDS (CloudWatch Logs), self-hosted (Filebeat) |
| MongoDB slow operations | durationMillis, nreturned, docsExamined, keysExamined, planSummary |
Self-hosted (Filebeat) |
For SQL Server, Azure SQL Database and SQL Managed Instance nothing extra is needed: the audit already carries the duration and row counts. For Azure Cosmos DB for MongoDB the duration comes in the audit record.
Step 1: turn the kind on in QubeSight¶
All kinds are off by default, because slow-operation logs increase volume at the source. While a kind is off, its incoming lines are not written and are counted in Platform → Pipeline → Flow (the in-app text says Pipeline → Flow).
- Open Data Sources → Stream Sources → Slow-operation logs.
- Turn on the kinds you need (On / Off). Changing them requires the administrator role and is written to the audit log.
- Optionally set Rate limit (per kind, per worker, per second).
0uses the default of 500 lines per second; lines above the limit are counted, not written. - For Azure PostgreSQL with a custom prefix, enter the same prefix under PostgreSQL log_line_prefix (Azure flexible server), or press Use the recommended prefix.
- Press Save. Workers apply the change within 30 seconds.
Each kind shows Written in the last 24 hours and Not written. How to turn it on? shows the steps per platform (Hide the steps closes them). Save confirms Saved. Workers apply it within 30 seconds.; other roles see You must be an administrator to change this.

Step 2: turn the log on in the database¶
Suggested thresholds: MySQL 1 second, MongoDB 100 ms, PostgreSQL 1000 ms. Lower values only while troubleshooting.
Azure flexible server
- Server parameters:
log_min_duration_statement = 1000(milliseconds). - The
PostgreSQLLogsdiagnostic category already goes to the Event Hub you use for auditing; nothing else is needed. - Optionally use the recommended
log_line_prefix(it adds the application%aand client host%h) and enter it in QubeSight too.
Amazon RDS
- Parameter group:
log_min_duration_statement = 1000. - Instance → Modify → Log exports: keep PostgreSQL log selected.
- The CloudWatch Logs or Kinesis source in QubeSight that reads this log group already receives the lines.
Statement and duration arrive in one line.
Azure flexible server
- Server parameters:
slow_query_log = ON,long_query_time = 1. - Diagnostic settings: add the
MySqlSlowLogscategory to the Event Hub you use for auditing.
Amazon RDS
- Parameter group:
slow_query_log = 1,long_query_time = 1,log_output = FILE. - Instance → Modify → Log exports: select Slow query log (
/aws/rds/instance/<name>/slowquery). - Add this log group to the QubeSight CloudWatch Logs integration.
Self-hosted
-
my.cnf: -
Add the file to Filebeat with multiline joining that starts a new event at a
# Time:or# User@Host:line.
Self-hosted
- At runtime:
db.setProfilingLevel(0, { slowms: 100 }). The profile collection stays empty; operations over 100 ms are written tomongod.logas "Slow query". -
Permanently, in
mongod.conf: -
Add
mongod.log(separate from the audit file) to Filebeat.
Amazon DocumentDB and MongoDB Atlas are out of scope.
Verification¶
- Run a statement that is slower than the threshold.
- On Data Sources → Stream Sources → Slow-operation logs, Written in the last 24 hours increases for the kind.
- Dashboards → Slow queries lists the SQL pattern with count, average, p95 and maximum duration, rows examined, server and user.
- In Reports, the matching audit event shows the response time with the "derived" badge.
Troubleshooting¶
| Symptom | Cause and action |
|---|---|
| Not written grows | The kind is off, or lines exceed the rate limit. |
| Measurements written but reports show no derived values | No audit event of the same session and server near the same time, for example because the audit source is not connected or misses session identifiers. |
| PostgreSQL lines land in the queue | The prefix on the server differs from the one entered in QubeSight. Lines whose split point is ambiguous are treated as untrusted and queued. |
Limitations¶
- Self-hosted PostgreSQL duration lines are read on the Azure and AWS paths only. Sent over syslog, they need a parse rule like any other syslog line and are then stored as events, not as measurements.
- A custom PostgreSQL prefix is parsed only in exactly the entered format, and
%a(application name, which the client controls) must be its last escape followed by a separator. - Linking a measurement to an event is done at query time by server, session and time window (and the SQL where available); it is a derived value, not part of the original audit record.