Archive for the ‘MongoDB’ Category

A few Splunk queries for MongoDB logs

Here’s a few Splunk queries I’ve used to supply some data for a dashboard I used to manage a MongoDB Cluster. Election events If any MongoDB elections happen at 3AM on a Wednesday night I want to know about it. This query, added to a single value panel allows me to do this easily… host=mongo* […]

Working with the PlanCache in MongoDB

I’ve been working a little with the PlanCache in MongoDB to troubleshoot some performance problems we’ve been experiencing. The contents of the Plan Cache are json documents (obviously) and this isn’t great to work with in the shell. Here’s a couple of javascript functions I’ve come up with to make things a little easier. These […]

mongodb_consistent_backup: A quick example

Just a quick post here to share some notes I made when using the mongodb_consistent_backup tool. This was performed on a installed of Red Hat Enterprise Linux Server release 7.2 (Maipo) running python 2.7.5. Install required packages and clone the tools repo; ?View Code BASHyum install python python-devel python-virtualenv gcc yum install mongodb-org-tools yum install git git clone […]

A quick mongofile demo

Here’s a few simple examples of using the mongofiles utility to use MongoDB GridFS to store, search and retrieve files. Upload a file into MongoDB into a database called gridfs ?View Code BASHmongofiles -u admin -padmin –authenticationDatabase admin –db gridfs put xfiles.504-amc.avi 2016-11-15T21:44:30.728+0100 connected to: localhost added file: xfiles.504-amc.avi Two collections will be created in the gridfs […]

Remove an _id field from a mongoexport json document

Although the mongoexport tool has a –fields option it will always include the _id field by default. You can remove this with a simple line of sed. This was slightly modified from this sed expression. Given the following data… ?View Code JSON{"_id":{"$oid":"57dd2809beed91a333ebe7d1"},"a":"Rhys"} {"_id":{"$oid":"57dd2810beed91a333ebe7d2"},"a":"James"} {"_id":{"$oid":"57dd2815beed91a333ebe7d3"},"a":"Campbell"} This command-line expression will export and munge the data… ?View Code BASHmongoexport […]