New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongo-slow-queries

Package Overview
Dependencies
Maintainers
15
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo-slow-queries

Utility for identifying slow queries in Mongo

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-77.78%
Maintainers
15
Weekly downloads
 
Created
Source

mongo-slow-queries

A module for pulling slow queries from Mongo, tagged with metadata as well.

Install

$ npm install mongo-slow-queries

Usage

Initialization

To use mongo-slow-queries you just need to provide a Mongo DB reference when creating an instance:

const mongojs = require('mongojs');
const MongoSlowQueryChecker = require('mongo-slow-queries');

let db = mongojs('mongodb://localhost:27017/admin');
let slowQueries = new MongoSlowQueryChecker({ db });

If the db object has an adminCommand method, it need not be a reference to the admin database.

Querying for slow queries

Querying for slow queries is then as simple as calling get:

slowQueries.get((err, queries) => {
  if (err) {
    console.log('Failed to retrieve slow queries: ' + queries);
  } else {
    console.log('slow queries: ' + JSON.stringify(queries));
  }
});

Query duration threshold

By default, mongo-slow-queries only returns queries that are currently running that have already taken greater than five seconds to run. If you wish to use a different threshold value, simply pass it in when you construct the Mongo slow query checker:

let slowQueries = new MongoSlowQueryChecker({
  db,
  queryThreshold: 2 // The unit of time is in seconds.
});

Changelog

  • 1.0.1 Fix which query we fingerprint.
  • 1.0.0 Initial release.

Keywords

FAQs

Package last updated on 04 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc