graylog-plugin-mongodb-profiler icon indicating copy to clipboard operation
graylog-plugin-mongodb-profiler copied to clipboard

Does not work with mongodb secondaries

Open nilroy opened this issue 9 years ago • 7 comments

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

nilroy avatar Dec 07 '15 13:12 nilroy

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 avatar Jan 12 '16 10:01 mrfreezer

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

mrfreezer avatar Jan 15 '16 15:01 mrfreezer

@lennartkoopmann Any update on this?

nilroy avatar Mar 02 '16 10:03 nilroy

Any update?

nilroy avatar Jun 10 '16 13:06 nilroy

@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.

mariussturm avatar Jun 10 '16 13:06 mariussturm

@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.

nilroy avatar Jun 10 '16 15:06 nilroy

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.

fadenb avatar Jul 13 '20 12:07 fadenb