SlideShare a Scribd company logo
#MongoDBdays @asya999 #askAsya 
Diagnostics and Debugging 
Asya Kamsky 
Principal Solutions Architect, MongoDB
#MongoDBdays @asya999 #askAsya 
Diagnostics and Debugging 
Asya Kamsky 
Principal Solutions Architect, MongoDB
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Understanding Crime Scene
Diagnostics and Debugging
“Data! Data! Data! 
I can't make bricks without 
clay.” 
-- Sherlock Holmes, 
The Adventure of the Copper Beeches 
9
Gathering Data
“It is a capital mistake to 
theorize before one has data. 
Insensibly one begins to twist 
facts to suit theories, instead 
of theories to suit facts.” 
-- Sherlock Holmes, A Scandal in 
Bohemia 
11
Diagnostics and Debugging
“There is nothing like first-hand evidence.” 
-- Sherlock Holmes, A Study in Scarlet
Available Tools: 
%mongostat 
%mongotop 
> db.currentOp( ), db.serverStatus( ) 
> rs.status( ) 
> sh.status( )
Available Tools: 
%mongostat 
%mongotop 
> db.currentOp( ), db.serverStatus( ) 
> rs.status( ) 
> sh.status( ) 
MongoDB Management Service (MMS) 
Monitoring
Available Tools: 
MongoDB Management Service (MMS) 
Monitoring
Available Tools: 
MongoDB Management Service (MMS) 
Monitoring
Available Tools: 
MongoDB Management Service (MMS) 
Monitoring
Available Tools: 
MongoDB Management Service (MMS) 
Monitoring
mongod logs
mongod logs 
Tue Jul 30 19:15:27.898 [conn2] query 
test.docs query: { query: { _id: { $gt: 
ObjectId('51da44a8a4435e3d7174b696') } 
}, orderby: { ts: 1.0 } } ntoreturn:10 
ntoskip:0 nscanned:9235093 
scanAndOrder:1 keyUpdates:0 numYields:5 
locks(micros) r:6919962 nreturned:1 
reslen:360 3578ms
mongod logs
mongod logs
"It is of the highest importance ... to be 
able to 
recognize, out of a number of facts, which 
are incidental and which vital. " 
Sherlock Holmes, The Reigate Puzzle
Diagnostics and Debugging
Diagnostics and Debugging
https://github.com/rueckstiess/mtools 
by Thomas Rückstieß
mtools 
• mloginfo 
• mlogfilter 
• mplotqueries 
• mlogvis 
• mlaunch
mtools 
• mloginfo 
• mlogfilter 
• mplotqueries
mloginfo 
source: logs/mongodb.log.2014-05-04T15-52-59 
start: 2014 May 02 00:29:21 
end: 2014 May 04 15:52:59 
date format: iso8601-local 
length: 17091234 
binary: mongod 
version: 2.6.0 
------------------------------------------ 
source: logs/mongodb.log.2014-05-04T15-53-06 
start: 2014 May 02 00:29:25 
end: 2014 May 04 15:53:06 
date format: iso8601-local 
length: 13696471 
binary: mongod 
version: 2.6.0
mplotqueries 
$mplotqueries--help 
usage: mplotqueries[OPTIONS] [logfile[logfile...]] 
A script to plot various information from logfiles. ...
mplotqueries 
$ mplotqueries--help 
usage: mplotqueries[OPTIONS] [logfile[logfile...]] 
A script to plot various information from logfiles. ... 
optional arguments: 
--type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} 
type of plot (default=scatter with --yaxisduration)
mplotqueries 
$ mplotqueries--help 
usage: mplotqueries[OPTIONS] [logfile[logfile...]] 
A script to plot various information from logfiles. ... 
optional arguments: 
--type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} 
type of plot (default=scatter with --yaxisduration)
mplotqueries 
$ mplotqueries--help 
usage: mplotqueries[OPTIONS] [logfile[logfile...]] 
A script to plot various information from logfiles. ... 
optional arguments: 
--type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} 
type of plot (default=scatter with --yaxisduration)
mplotqueries 
$ mplotqueries--help 
usage: mplotqueries[OPTIONS] [logfile[logfile...]] 
A script to plot various information from logfiles. ... 
optional arguments: 
--type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} 
type of plot (default=scatter with --yaxisduration)
mplotqueries 
$ mplotqueries--help 
usage: mplotqueries[OPTIONS] [logfile[logfile...]] 
A script to plot various information from logfiles. ... 
optional arguments: 
--type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} 
type of plot (default=scatter with --yaxisduration)
mplotqueries 
$ mplotqueries--help 
usage: mplotqueries[OPTIONS] [logfile[logfile...]] 
A script to plot various information from logfiles. ... 
optional arguments: 
--type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} 
type of plot (default=scatter with --yaxisduration)
mplotqueries 
$ mplotqueries--help 
usage: mplotqueries[OPTIONS] [logfile[logfile...]] 
A script to plot various information from logfiles. ... 
optional arguments: 
--type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} 
type of plot (default=scatter with --yaxisduration)
mplotqueries 
$ mplotqueries--help 
usage: mplotqueries[OPTIONS] [logfile[logfile...]] 
A script to plot various information from logfiles. ... 
optional arguments: 
--type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} 
type of plot (default=scatter with --yaxisduration) 
--group GROUP specify value to group on. 
All basic plot types can group on 
'namespace', 'operation', 'thread', 'pattern' ...
Diagnostics and Debugging
"... what is out of the common is usually a 
guide 
rather than a hindrance." 
— Sherlock Holmes, A Study in 
Scarlet
The Adventure of the Missing 
Three-Quarter (Indexes)
mloginfo 
$ mloginfofirstmongo.log 
source: firstmongo.log 
start: 2014 Jun 10 11:19:54 
end: 2014 Jun 17 17:14:15 
date format: iso8601-local 
length: 14170668 
binary: mongod 
version: 2.6.1 
mloginfofirstmongo.log--queries
mloginfo 
$mloginfofirstmongo.log 
source: firstmongo.log 
start: 2014 Jun 10 11:19:54 
end: 2014 Jun 17 17:14:15 
date format: iso8601-local 
length: 14170668 
binary: mongod 
version: 2.6.1 
mloginfofirstmongo.log–-queries 
namespace pattern count max (ms) mean (ms) 95%-ile(ms) sum (ms) 
db1.request {"requestSender": 1} 29 350161 93828 339441.2 2721018 
db1.request {"curRoute": 1,"isAdv": 1 } 169 9585 3942 6324.2 666302 
db1.report {"deliveryTime": 1} 9 111421 71536 106609.4 643829 
db2.report {"deliveryTime": 1} 10 85267 60363 81508.15 603634 
db3.report {"deliveryTime": 1} 10 72071 53062 70781.3 530624 
db1.pending {"sentTime": 1, "status": 1} 9 108734 38013 88470.4 342117
mplotqueries 
% mplotqueriesfirstmongo.log--type nscanned/n
mplotqueries 
% mplotqueriesfirstmongo.log--type nscanned/n
mplotqueries 
% mplotqueriesfirstmongo.log--type nscanned/n 
2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: 
COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 
nreturned:72reslen:32707 30129ms
mplotqueries 
% mplotqueriesfirstmongo.log--type nscanned/n 
2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: 
COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 
nreturned:72reslen:32707 30129ms
mplotqueries 
% mplotqueriesfirstmongo.log--type nscanned/n 
2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: 
COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 
nreturned:72reslen:32707 30129ms
mplotqueries 
% mplotqueriesfirstmongo.log--type nscanned/n 
2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: 
COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 
nreturned:72reslen:32707 30129ms 
2014-06-17T17:13:47.607 [conn1569990] query db2.coll query: { time: { $lt: "2014-06-17 17:14:05", $gte: "2014-06-17 17:05:05" }, status: 8 } 
planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:2057564nscannedObjects:2057564 keyUpdates:0 numYields:5008 locks(micros) 
r:11557172 nreturned:56reslen:18745 13086ms
mplotqueries 
% mplotqueriesfirstmongo.log--type nscanned/n 
2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: 
COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 
nreturned:72reslen:32707 30129ms 
2014-06-17T17:13:47.607 [conn1569990] query db2.coll query: { time: { $lt: "2014-06-17 17:14:05", $gte: "2014-06-17 17:05:05" }, status: 8 } 
planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:2057564nscannedObjects:2057564 keyUpdates:0 numYields:5008 locks(micros) 
r:11557172 nreturned:56reslen:18745 13086ms
mplotqueries 
% mplotqueriesfirstmongo.log--type nscanned/n 
2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: 
COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 
nreturned:72reslen:32707 30129ms 
2014-06-17T17:13:47.607 [conn1569990] query db2.coll query: { time: { $lt: "2014-06-17 17:14:05", $gte: "2014-06-17 17:05:05" }, status: 8 } 
planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:2057564nscannedObjects:2057564 keyUpdates:0 numYields:5008 locks(micros) 
r:11557172 nreturned:56reslen:18745 13086ms
The Sign of Four (Shards)
% mplotqueriesupdates?.log
% mplotqueriesupdates?.log
% mplotqueriesupdates?.log
% mplotqueriesupdates?.log
% mplotqueriesupdates?.log
"Eliminate all other factors, and the 
one which remains must be the truth." 
Sherlock Holmes -The Sign of Four 
59
The Case of Identity
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
% mplotqueries–type histogram –group namespace –bucketSize3600
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
The Stockbroker's Clerk's 
Query
Diagnostics and Debugging
% mplotqueries–type connchurn
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
Diagnostics and Debugging
"We balance probabilities and 
choose the most likely. It is the 
scientific use of the 
imagination." 
Sherlock Holmes, The Hound of the Baskervilles 
With profound thanks to: 
Sir Arthur Conan Doyle (1859-1930)
#MongoDBdays @asya999 
Thank You 
Asya Kamsky 
MongoDB, Inc. 
http://askasya.com/ 
http://www.kamsky.org/

More Related Content

PDF
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
PPTX
Building Your First Data Science Applicatino in MongoDB
PDF
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
PDF
20110514 mongo dbチューニング
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
PDF
Neo4j after 1 year in production
PDF
はじめてのMongoDB
PDF
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
Building Your First Data Science Applicatino in MongoDB
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
20110514 mongo dbチューニング
Wprowadzenie do technologi Big Data i Apache Hadoop
Neo4j after 1 year in production
はじめてのMongoDB
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...

What's hot (19)

PDF
Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...
ODP
Intravert Server side processing for Cassandra
PDF
MongoDB: Optimising for Performance, Scale & Analytics
PDF
Groovy.pptx
PDF
Monitoring MongoDB (MongoSV)
PDF
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
PDF
glance replicator
PDF
Redis for the Everyday Developer
PPTX
MongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
PDF
MongoDB - Monitoring & queueing
PDF
Programming with Python and PostgreSQL
PDF
Parsing JSON Really Quickly: Lessons Learned
PDF
Practical JSON in MySQL 5.7 and Beyond
PDF
Inside MongoDB: the Internals of an Open-Source Database
PDF
Kicking ass with redis
ODP
2012 07-24 dnssec-og_open_dnssec_-_martin_toft_og_georg_sluyterman_slideshow
PPTX
OWASP AppSecCali 2015 - Marshalling Pickles
PDF
Practical JSON in MySQL 5.7
PDF
Optimizing Slow Queries with Indexes and Creativity
Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...
Intravert Server side processing for Cassandra
MongoDB: Optimising for Performance, Scale & Analytics
Groovy.pptx
Monitoring MongoDB (MongoSV)
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
glance replicator
Redis for the Everyday Developer
MongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
MongoDB - Monitoring & queueing
Programming with Python and PostgreSQL
Parsing JSON Really Quickly: Lessons Learned
Practical JSON in MySQL 5.7 and Beyond
Inside MongoDB: the Internals of an Open-Source Database
Kicking ass with redis
2012 07-24 dnssec-og_open_dnssec_-_martin_toft_og_georg_sluyterman_slideshow
OWASP AppSecCali 2015 - Marshalling Pickles
Practical JSON in MySQL 5.7
Optimizing Slow Queries with Indexes and Creativity
Ad

Similar to Diagnostics and Debugging (20)

PDF
Diagnostics & Debugging webinar
PDF
MongoDB Europe 2016 - Debugging MongoDB Performance
PDF
Application Logging in the 21st century - 2014.key
PDF
NSC #2 - Challenge Solution
ODP
Mongo db dla administratora
PDF
Nodejs性能分析优化和分布式设计探讨
PDF
MongoDB - Monitoring and queueing
PPTX
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
PPT
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
PPT
How ElasticSearch lives in my DevOps life
PDF
Large Scale Log Analytics with Solr (from Lucene Revolution 2015)
PDF
MongoDB dla administratora
PDF
Why you should be using structured logs
PDF
marko_go_in_badoo
PPTX
Deep dive_ Collect and process your logs on K8s with Opentelemetry Collector....
PDF
Rapid Prototyping with Solr
PPTX
Attack monitoring using ElasticSearch Logstash and Kibana
PDF
Anwendungsfaelle für Elasticsearch
PDF
Security Monitoring for big Infrastructures without a Million Dollar budget
PDF
rsyslog v8: more than just syslog!
Diagnostics & Debugging webinar
MongoDB Europe 2016 - Debugging MongoDB Performance
Application Logging in the 21st century - 2014.key
NSC #2 - Challenge Solution
Mongo db dla administratora
Nodejs性能分析优化和分布式设计探讨
MongoDB - Monitoring and queueing
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
How ElasticSearch lives in my DevOps life
Large Scale Log Analytics with Solr (from Lucene Revolution 2015)
MongoDB dla administratora
Why you should be using structured logs
marko_go_in_badoo
Deep dive_ Collect and process your logs on K8s with Opentelemetry Collector....
Rapid Prototyping with Solr
Attack monitoring using ElasticSearch Logstash and Kibana
Anwendungsfaelle für Elasticsearch
Security Monitoring for big Infrastructures without a Million Dollar budget
rsyslog v8: more than just syslog!
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Empathic Computing: Creating Shared Understanding
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
MYSQL Presentation for SQL database connectivity
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation_ Review paper, used for researhc scholars
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25-Week II
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Spectroscopy.pptx food analysis technology
MIND Revenue Release Quarter 2 2025 Press Release
Per capita expenditure prediction using model stacking based on satellite ima...
Empathic Computing: Creating Shared Understanding
“AI and Expert System Decision Support & Business Intelligence Systems”
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Mobile App Security Testing_ A Comprehensive Guide.pdf
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
sap open course for s4hana steps from ECC to s4
Programs and apps: productivity, graphics, security and other tools
MYSQL Presentation for SQL database connectivity

Diagnostics and Debugging

  • 1. #MongoDBdays @asya999 #askAsya Diagnostics and Debugging Asya Kamsky Principal Solutions Architect, MongoDB
  • 2. #MongoDBdays @asya999 #askAsya Diagnostics and Debugging Asya Kamsky Principal Solutions Architect, MongoDB
  • 9. “Data! Data! Data! I can't make bricks without clay.” -- Sherlock Holmes, The Adventure of the Copper Beeches 9
  • 11. “It is a capital mistake to theorize before one has data. Insensibly one begins to twist facts to suit theories, instead of theories to suit facts.” -- Sherlock Holmes, A Scandal in Bohemia 11
  • 13. “There is nothing like first-hand evidence.” -- Sherlock Holmes, A Study in Scarlet
  • 14. Available Tools: %mongostat %mongotop > db.currentOp( ), db.serverStatus( ) > rs.status( ) > sh.status( )
  • 15. Available Tools: %mongostat %mongotop > db.currentOp( ), db.serverStatus( ) > rs.status( ) > sh.status( ) MongoDB Management Service (MMS) Monitoring
  • 16. Available Tools: MongoDB Management Service (MMS) Monitoring
  • 17. Available Tools: MongoDB Management Service (MMS) Monitoring
  • 18. Available Tools: MongoDB Management Service (MMS) Monitoring
  • 19. Available Tools: MongoDB Management Service (MMS) Monitoring
  • 21. mongod logs Tue Jul 30 19:15:27.898 [conn2] query test.docs query: { query: { _id: { $gt: ObjectId('51da44a8a4435e3d7174b696') } }, orderby: { ts: 1.0 } } ntoreturn:10 ntoskip:0 nscanned:9235093 scanAndOrder:1 keyUpdates:0 numYields:5 locks(micros) r:6919962 nreturned:1 reslen:360 3578ms
  • 24. "It is of the highest importance ... to be able to recognize, out of a number of facts, which are incidental and which vital. " Sherlock Holmes, The Reigate Puzzle
  • 28. mtools • mloginfo • mlogfilter • mplotqueries • mlogvis • mlaunch
  • 29. mtools • mloginfo • mlogfilter • mplotqueries
  • 30. mloginfo source: logs/mongodb.log.2014-05-04T15-52-59 start: 2014 May 02 00:29:21 end: 2014 May 04 15:52:59 date format: iso8601-local length: 17091234 binary: mongod version: 2.6.0 ------------------------------------------ source: logs/mongodb.log.2014-05-04T15-53-06 start: 2014 May 02 00:29:25 end: 2014 May 04 15:53:06 date format: iso8601-local length: 13696471 binary: mongod version: 2.6.0
  • 31. mplotqueries $mplotqueries--help usage: mplotqueries[OPTIONS] [logfile[logfile...]] A script to plot various information from logfiles. ...
  • 32. mplotqueries $ mplotqueries--help usage: mplotqueries[OPTIONS] [logfile[logfile...]] A script to plot various information from logfiles. ... optional arguments: --type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} type of plot (default=scatter with --yaxisduration)
  • 33. mplotqueries $ mplotqueries--help usage: mplotqueries[OPTIONS] [logfile[logfile...]] A script to plot various information from logfiles. ... optional arguments: --type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} type of plot (default=scatter with --yaxisduration)
  • 34. mplotqueries $ mplotqueries--help usage: mplotqueries[OPTIONS] [logfile[logfile...]] A script to plot various information from logfiles. ... optional arguments: --type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} type of plot (default=scatter with --yaxisduration)
  • 35. mplotqueries $ mplotqueries--help usage: mplotqueries[OPTIONS] [logfile[logfile...]] A script to plot various information from logfiles. ... optional arguments: --type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} type of plot (default=scatter with --yaxisduration)
  • 36. mplotqueries $ mplotqueries--help usage: mplotqueries[OPTIONS] [logfile[logfile...]] A script to plot various information from logfiles. ... optional arguments: --type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} type of plot (default=scatter with --yaxisduration)
  • 37. mplotqueries $ mplotqueries--help usage: mplotqueries[OPTIONS] [logfile[logfile...]] A script to plot various information from logfiles. ... optional arguments: --type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} type of plot (default=scatter with --yaxisduration)
  • 38. mplotqueries $ mplotqueries--help usage: mplotqueries[OPTIONS] [logfile[logfile...]] A script to plot various information from logfiles. ... optional arguments: --type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} type of plot (default=scatter with --yaxisduration)
  • 39. mplotqueries $ mplotqueries--help usage: mplotqueries[OPTIONS] [logfile[logfile...]] A script to plot various information from logfiles. ... optional arguments: --type{nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} type of plot (default=scatter with --yaxisduration) --group GROUP specify value to group on. All basic plot types can group on 'namespace', 'operation', 'thread', 'pattern' ...
  • 41. "... what is out of the common is usually a guide rather than a hindrance." — Sherlock Holmes, A Study in Scarlet
  • 42. The Adventure of the Missing Three-Quarter (Indexes)
  • 43. mloginfo $ mloginfofirstmongo.log source: firstmongo.log start: 2014 Jun 10 11:19:54 end: 2014 Jun 17 17:14:15 date format: iso8601-local length: 14170668 binary: mongod version: 2.6.1 mloginfofirstmongo.log--queries
  • 44. mloginfo $mloginfofirstmongo.log source: firstmongo.log start: 2014 Jun 10 11:19:54 end: 2014 Jun 17 17:14:15 date format: iso8601-local length: 14170668 binary: mongod version: 2.6.1 mloginfofirstmongo.log–-queries namespace pattern count max (ms) mean (ms) 95%-ile(ms) sum (ms) db1.request {"requestSender": 1} 29 350161 93828 339441.2 2721018 db1.request {"curRoute": 1,"isAdv": 1 } 169 9585 3942 6324.2 666302 db1.report {"deliveryTime": 1} 9 111421 71536 106609.4 643829 db2.report {"deliveryTime": 1} 10 85267 60363 81508.15 603634 db3.report {"deliveryTime": 1} 10 72071 53062 70781.3 530624 db1.pending {"sentTime": 1, "status": 1} 9 108734 38013 88470.4 342117
  • 47. mplotqueries % mplotqueriesfirstmongo.log--type nscanned/n 2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 nreturned:72reslen:32707 30129ms
  • 48. mplotqueries % mplotqueriesfirstmongo.log--type nscanned/n 2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 nreturned:72reslen:32707 30129ms
  • 49. mplotqueries % mplotqueriesfirstmongo.log--type nscanned/n 2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 nreturned:72reslen:32707 30129ms
  • 50. mplotqueries % mplotqueriesfirstmongo.log--type nscanned/n 2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 nreturned:72reslen:32707 30129ms 2014-06-17T17:13:47.607 [conn1569990] query db2.coll query: { time: { $lt: "2014-06-17 17:14:05", $gte: "2014-06-17 17:05:05" }, status: 8 } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:2057564nscannedObjects:2057564 keyUpdates:0 numYields:5008 locks(micros) r:11557172 nreturned:56reslen:18745 13086ms
  • 51. mplotqueries % mplotqueriesfirstmongo.log--type nscanned/n 2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 nreturned:72reslen:32707 30129ms 2014-06-17T17:13:47.607 [conn1569990] query db2.coll query: { time: { $lt: "2014-06-17 17:14:05", $gte: "2014-06-17 17:05:05" }, status: 8 } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:2057564nscannedObjects:2057564 keyUpdates:0 numYields:5008 locks(micros) r:11557172 nreturned:56reslen:18745 13086ms
  • 52. mplotqueries % mplotqueriesfirstmongo.log--type nscanned/n 2014-06-17T17:13:34.235 [conn1569841] query db1.coll query: { time: { $lt: "2014-06-17 17:13:31", $gte: "2014-06-17 17:04:31" } } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:5169727nscannedObjects:5169727 keyUpdates:0 numYields:12492 locks(micros) r:37736571 nreturned:72reslen:32707 30129ms 2014-06-17T17:13:47.607 [conn1569990] query db2.coll query: { time: { $lt: "2014-06-17 17:14:05", $gte: "2014-06-17 17:05:05" }, status: 8 } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 nscanned:2057564nscannedObjects:2057564 keyUpdates:0 numYields:5008 locks(micros) r:11557172 nreturned:56reslen:18745 13086ms
  • 53. The Sign of Four (Shards)
  • 59. "Eliminate all other factors, and the one which remains must be the truth." Sherlock Holmes -The Sign of Four 59
  • 60. The Case of Identity
  • 64. % mplotqueries–type histogram –group namespace –bucketSize3600
  • 86. "We balance probabilities and choose the most likely. It is the scientific use of the imagination." Sherlock Holmes, The Hound of the Baskervilles With profound thanks to: Sir Arthur Conan Doyle (1859-1930)
  • 87. #MongoDBdays @asya999 Thank You Asya Kamsky MongoDB, Inc. http://askasya.com/ http://www.kamsky.org/

Editor's Notes

  • #12: V 1.3
  • #35: scatter; histograms; connection churn; range; replica set state plot; ability to overlay several types of plots.
  • #58: logs for all the primaries and I filter out just updates and plot them on a scatter plot here Y axis is duration and X-axis is time. I grouped "by shard" or by "file" so you can see easily that there are clusters of like colors at least in some parts of the graph. Clicking on each color in the upper right corner will hide that color from the graph so I decided to hide all colors and look at each of the shards one at a time.
  • #68: The obvious spike in $addToSet operations for the last day on the activity.followed_entities collection, that explained the falling over, but why the slowdown?
  • #83: we can ZOOM. now double click on point to show duration. SUMMARIZE WHAT HAPPENED! no ad hoc! no unindexed queries!