graylog-labs / graylog-plugin-mongodb-profiler

Graylog input plugin that reads MongoDB profiler data
https://www.graylog.org/
GNU General Public License v3.0
18 stars 10 forks source link

Does not work with mongodb secondaries #4

Open nilroy opened 9 years ago

nilroy commented 9 years ago

I have enabled profiling for both the primary and secondary mongodb (we are using replica set). Profiling level being 2 (that is profiling all queries). But only those queries executed against the master are shown in graylog. Is it designed to do so or I am missing something?

I am using mongodb 3.0

mrfreezer commented 8 years ago

i would like to confirm this for mongodb 2.4 as well. (1 primary, 1 secondary) this is what i see in the graylog-server logfile as soon as i start the input pointing to the secondary:

2016-01-12T11:20:42.922+01:00 ERROR [ProfileSubscriber] Error when reading MongoDB profile information. Retrying.
com.mongodb.MongoException: not talking to master and retries used up
        at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:323)
        at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:325)
        at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:325)
        at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:273)
        at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:84)
        at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:66)
        at com.mongodb.DBCursor._check(DBCursor.java:498)
        at com.mongodb.DBCursor._hasNext(DBCursor.java:621)
        at com.mongodb.DBCursor.hasNext(DBCursor.java:657)
        at com.graylog2.inputs.mongoprofiler.input.mongodb.ProfileSubscriber.run(ProfileSubscriber.java:83)

for me this looks like the input (or the mongodb-driver inside java if that one is used) refuses to talk to a secondary (since i can "manually" look at the profiling on a secondary via the mongo-console this doesn't look like a mongo-db issue to me)

for me this renders the input rather useless since most queries are executed on the secondary, especially the time consuming ones...

ingo

mrfreezer commented 8 years ago

a little more research tells me that the solution might be rather easy. mongodb reports in its logs (on the secondary) that the query should not be executed on slaves:

 
assertion 13435 not master and slaveOk=false ns:xxxxxx.system.profile query

which, in my limited concept of mongodb means all you have to do is extend your query which is polling the profiling log with a "slaveOk=yes" to make it work.

to bad i am so not into java programming otherwise i would have tried to fix it myself instead of just smart-assing around ;)

ingo

nilroy commented 8 years ago

@lennartkoopmann Any update on this?

nilroy commented 8 years ago

Any update?

mariussturm commented 8 years ago

@nilroy please dont ask for status updates all the time. When something changes people will leave a note here. Open source is about contributing not pushing others.

Thanks.

nilroy commented 8 years ago

@mariussturm Sorry if I bothered anybody. I am not trying to push anybody. And I know that what opensource is all about. If I would be a Java guy I would have tried to fix it atleast. I expected a reply like if someone is working or it would take time. I was just wandering what happened to this as it was opened for long time. I would appreciate if this issue is labelled or classified. Sorry if I bothered again.

fadenb commented 4 years ago

a little more research tells me that the solution might be rather easy. mongodb reports in its logs (on the secondary) that the query should not be executed on slaves:

assertion 13435 not master and slaveOk=false ns:xxxxxx.system.profile query which, in my limited concept of mongodb means all you have to do is extend your query which is polling the profiling log with a "slaveOk=yes" to make it work.

to bad i am so not into java programming otherwise i would have tried to fix it myself instead of just smart-assing around ;)

ingo

You can try executing rs.slaveOK() in a MongoDB client to allow those queries on a slave without modifying the code. Just keep in mind to persist this so it does not break when you have to restart your MongoDB.