<!-- llms-explorer concept facts · https://llms-explorer.com/tree/mongod-diagnostic-log-slow-query-format-and-slowopsamplerate/ · pack 2026-10-31 · ~1403 tokens -->

# mongod diagnostic log slow-query format and slowOpSampleRate

> Source-anchored research for mongod diagnostic log slow-query format and slowOpSampleRate. Run status: COMPLETED.

Parent: [Database Profiler vs Query Profiler](https://llms-explorer.com/tree/database-profiler-vs-query-profiler/) · 4 facets · 13 facts · page: https://llms-explorer.com/tree/mongod-diagnostic-log-slow-query-format-and-slowopsamplerate/

## How it works

- The runtime sampleRate option in db.setProfilingLevel() and the startup slowOpSampleRate option control the same sampling setting. Runtime slowms and sampleRate settings apply across databases within the process, while runtime profiling level and filter settings are per database. (high confidence) — [source](https://www.mongodb.com/docs/manual/tutorial/manage-the-database-profiler.md)

## Problems, failure modes and limitations

- At logLevel 0, slowOpSampleRate randomly selects a fraction of eligible slow operations for the diagnostic log. The configuration value accepts 0 through 1 inclusive and defaults to 1.0; a rate of 0.5 represents random sampling, not a guarantee to record every second operation. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/configuration-options.md)
- At logLevel 0, eligible slow commands enter the diagnostic log with the configured sample probability. At higher logLevel settings, command logging bypasses that sampling restriction; increasing verbosity can therefore defeat an intended reduction in command-log volume. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/configuration-options/)
- At profiling level 1, a configured profiling filter selects profiled operations and bypasses slowms and sampleRate. Profiling level 2 collects all operations and ignores the filter. A configured diagnostic-log filter also bypasses slow-operation threshold and sampling settings for log selection. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/configuration-options.md)
- mongos supports slow-operation diagnostic logging but has no database profiler. On mongod, slowOpSampleRate affects diagnostic logging and the profiler when enabled; router logging therefore cannot substitute for configuring the relevant shard mongod process. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/configuration-options.md)
- Percona Server for MongoDB 4.0 documents rateLimit as a profiler-level-2 mechanism that samples fast operations, retains slow operations and does not affect the log file. Its comparison explicitly distinguishes sampleRate, which can discard slow operations and affects log output; these options are not interchangeable. (low confidence) — [source](https://docs.percona.com/percona-server-for-mongodb/4.0/rate-limit.html)
- A missing slow-operation log record is inconclusive when eligible operations are sampled below 1.0. For comparisons across nodes, preserve the effective sample rate, threshold, filter, and verbosity with the log evidence; this is an inference from the capture rules and the diagnostic-context problem described in SERVER-55069. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/configuration-options/)
- Diagnostic slow-query records can include namespace, command, and plan information inside attr. The dbi-services operational example demonstrates these fields in a Slow query record; the official logging reference defines attr as the structured carrier of additional event data. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/log-messages.md)
- Diagnostic slow-operation logging is distinct from storing profiler records in system.profile. Setting profiling level 0 disables profiler collection but can still configure slow-operation logging through slowms and sampleRate; an empty profiler collection therefore does not establish that diagnostic slow-query logging is disabled. (high confidence) — [source](https://www.mongodb.com/docs/manual/tutorial/manage-the-database-profiler.md)
- Higher logLevel settings can place client operations in the diagnostic log regardless of latency. Diagnose unexpectedly high log volume by checking verbosity as well as slow-operation thresholds and sampling; secondary oplog application remains a documented exception to logging all operations. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/configuration-options.md)

## Comparisons and alternatives

- Modern mongod and mongos diagnostic logs use self-contained structured JSON objects. The envelope identifies timestamp, severity, component, log-statement identifier, thread context and message; optional attr holds additional event attributes. The id identifies a log statement type rather than a unique operation invocation. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/log-messages.md)
- Slow secondary oplog-application messages use the REPL component, are affected by slowOpSampleRate, do not depend on profiling or log verbosity levels, and are not captured by the profiler. They describe replication application rather than a client secondary read. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/log-messages.md)

## Facts and statements

- MongoDB documents attribute truncation controlled by maxLogSizeKB and exposes truncated metadata while preserving JSON parseability. Thus a valid log record does not guarantee that the original command attribute is complete. (low confidence) — [source](https://www.mongodb.com/docs/manual/reference/log-messages.md)
