sonian / elasticsearch-jetty

Apache License 2.0
284 stars 79 forks source link

Log 'requestId' for intra-cluster log correlation #16

Open tallpsmith opened 12 years ago

tallpsmith commented 12 years ago

Well, first, thanks for this plugin, tried this locally in my dev environment and worked a treat, we're definitely going to use this in production.

However, what would be extra-awesome is if this plugin could allow the requesting client application to pass on a 'requestId' that correlates any ES logs with a unique requestID handle. What we do is when a user interacts with our site, a unique requestId token is generated and bundled as a threadLocal, and use log4j's MDC concept so that all user logs for that requestId have that requestId in them, allowing very simple filtering to find all logs for a given request.

Now when a client app interacts with something like ES, it would be great for the ES api to be able to pass on this requestID in the headers so that the logging on the ES side also has the same thing. This way all ES queries/interactions for a given user base action could be logged and correlated together.

ES has the X-Opaque-Id header which I had planned to look at as part of trying this myself, see https://github.com/elasticsearch/elasticsearch/issues/1202 but maybe this plugin is the best place to do it.

For reference, we're building up to something like Google's Dapper (http://research.google.com/pubs/pub36356.html) where by in a distributed system unique requests can be identified (we're sticking with a single 'span' concept though at this stage).

Love to have your comments, and thanks again for a great plugin.

imotov commented 12 years ago

As a workaround, you can repeat this id as a parameter on URL and it will be logged.