I have been trying to log the query the user performs on the Kibana Discover tab into the stdout of the Kibana server.
I can see from the browser see that every time the user performs a search, a POST request is made to the "/elasticsearch/_msearch" containing the query, so I was trying to develop a plugin that hooks hapijs on the request and prints the POST payload to the kibana log:
On my plugin index.js (generated with yo), I added:
server.on('response', function (request) {
console.log('Request payload:', request.payload);
}
Inside the init(server, options) section.
This successfully outputs the request being made, but I am unable to get the actual POST content
I also tried with:
server.ext('onPreHandler', function (request, reply) {
server.log(['info'],request);
return reply.continue();
}
But also without success.
Meanwhile I figured I can also see the query in the "spy tab" but from there I don't think its possible to log on the kibana server stdout from there...
Any hints on an approach to accomplish this? My final goal is to log both the user logged in kibana (w/ x-pack enabled) and the query he performed (any tips on how to get the username is also appreciated).
Thanks!