Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mongo] Connection DB should be separate from monitored DB(s) #1961

Merged
merged 1 commit into from
Oct 9, 2015

Conversation

truthbk
Copy link
Member

@truthbk truthbk commented Oct 1, 2015

This fix attempts to address what is described here: #1855

Two main things have been done:

  • We now collect mongodb dbstats for each DB running on the cluster/host and return them with an associated tag cluster:db:foo where foo would be the database name.
    • We now also correctly deal with replica sets. While getting the integration tests to work I found an issue with the way we were attempting to collect replica set stats. These commands can only be made against the 'admin' db (which always exists I believe), so we now issue replicaset commands against it.

Also, since pymongo.Connection is deprecated, I changed this over to use MongoClient which is the preferred way to do so. Finally, the api_key was causing issues when creating an event when dealing with some of the replicaset data and creating events - older integration tests were not picking up on this because replicaset's were essentially not being handled originally.

Integration tests are good. Local tests against docker are good.

Some refactoring may be in order. Also note my python game definitely need polishing - so any comments are welcome.

@truthbk truthbk assigned yannmh and hkaj and unassigned yannmh Oct 1, 2015

self.event({
'timestamp': int(time.time()),
'event_type': 'Mongo',
'api_key': agentConfig['api_key'],
'api_key': api_key,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can replace the modifications above with
'api_key': agentConfig.get('api_key', ''),
here

@hkaj
Copy link
Member

hkaj commented Oct 8, 2015

LGTM, just need to rebase.

Fix get database names via pymongo.

Reusing the conn object was failing.

No need to reauthenticate.

Fixing typo.

pymongo.Connection is deprecated, favoring MongoClient.

socket timeout now expressed in milliseconds w/ MongoClient

fixing typo.

We were appending multiple times to the same list.

ReplicaSet have to be defined when declaring a MongoClient. Also, the replicaset events were orginally ignored if not targeting the admin db, they should now always work.

Fixing pep8 and flake8 issues.

Pythonic dict lookup, instead of ugly if.

Typo, how did api_key end up in a list?

Improvements following Haissams cue towards a more pythonic code.

Fixing a couple of long lines.

No need to de-dupe tags again there.
@truthbk truthbk force-pushed the jaime/mongo-clustermon-fix branch from 801998e to 6ffbd4f Compare October 9, 2015 17:27
truthbk added a commit that referenced this pull request Oct 9, 2015
[mongo] Connection DB should be separate from monitored DB(s)
@truthbk truthbk merged commit 06981c4 into master Oct 9, 2015
@hkaj
Copy link
Member

hkaj commented Oct 13, 2015

Don't forget to remove your branch from Github once you're all set :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants