MongoDB-Redis Queries Logging

Photo by Caspar Camille Rubin on Unsplash
Assume you have an Application and you have to keep an eye on MongoDB’s queries or you want to track all Redis operations in order to optimize your application performance, the question which will jump to your mind how can i do that ?
following this article you will be able to do that.

1- MongoDB Logging using Mongotail

I am going to use mongotail which is command line tool to outputs any operation from a Mongo database in the standard output

Install

pip install mongotail

Get started

I built a small NodeJs app to insert, query and drop this JSON data

{"name":"test","location":"dubai","subject":"demo"}

First, we have to set log level to 2 to list all the operations [Enable Logging]

Second, tail the logs so we can see all queries [List All the operations]

The results will be

insert & query & remove operations

2- Redis Logging using Monitor

Debugging command that streams back every command processed by the Redis server.

Example

Assume we have some set and get operations on Redis server

Now run [then do any operations on Redis]

redis-cli  monitor
it streams all the operations

Filtering only set and get

redis-cli  monitor | grep -E 'get|set'
now we have only set and get operations