palash kulshreshtha palash kulshreshtha - 1 year ago 101
Node.js Question

Where to find what queries are hitting to gremlin server via gremlin-javascript

I am using gremlin-javascript module of nodejs to query titab database. Everything is working fine but I want to monitor what is actually hitting the gremlin server and anything else that i can get to know about that query. I already checked the gremlin-server log in logs folder inside the titan folder . I can not find anything of use in those logs. Any help in this regard will be extremely useful. thanks

Answer Source

For a client side solution with gremlin-javascript, there is currently no quick and easy way to log to the console outgoing queries or protocol messages sent to Gremlin Server.

You could either:

  1. Implement your own function that wraps calls to the Gremlin client methods you call (typically client.execute()), and logs arguments. If using Node.js v6+, this could be a nice use case for an ES2015 Proxy object. This is the safest, non intrusive approach.
  2. Monkeypatch the client.prototype.messageStream method, and log parameters. As of v2.3.2, this low level method gets called whether you're doing client.execute() or This is riskier and trickier.
  3. Quick and dirty: edit the source code in ./node_modules/gremlin/lib/GremlinClient.js and add this after line 405 (prototype.messageStream definition):

    console.log('query:', script);
    console.log('params:', bindings);

There's currently an open issue about logging of ingoing messages but this could be developed to include outgoing messages as well (queries with parameters, down to protocol messages).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download