Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-15501

Setting a filter with db.setProfilingLevel(2) is not working

      Hello team,

      The below example is misleading, I have found out that this example is not working.


      For example, the following db.setProfilingLevel() method sets for a mongod instance:

      • the profiling level to 2,
      • the filter of { op: "query", millis: { $gt: 2000 }}, which causes the profiler to only log query operations that took longer than 2 seconds.
      db.setProfilingLevel( 2, { filter: { op: "query", millis: { $gt: 2000 } } } )

      To me, the filter for Data Profiler works with db.setProfilingLevel( 1 ) only.

      db.setProfilingLevel( 1, { filter: { op: "query", millis: { $gt: 2000 } } } )


      Which makes sense with the below description 


      Level Description
      0 The profiler is off and does not collect any data. This is the default profiler level.
      1 The profiler collects data for operations that take longer than the value of slowms or that match a filter.
      When a filter is set:
      • The slowms and sampleRate options are not used for profiling.
      • The profiler only captures operations that match the filter.
      2 The profiler collects data for all operations.



      Can you please check this out and rectify the example?

            jason.price@mongodb.com Jason Price
            peter.oh@mongodb.com Peter Oh
            0 Vote for this issue
            2 Start watching this issue

              1 year, 45 weeks, 5 days ago