One way to achieve this without code changes in Solr is to provide the
"rid" parameter, you'd have to make your client add the "rid" parameter in
requests explicitly instead of (or in addition to) the x-correlation-id
header. The "rid" is logged in the different phases of the request, even in
the case of distributed search requests.
In addition to this, if you have request logs enabled[1], you could log the
http header by providing a custom request log format[2]. Do know that the
header won't be automatically included in internal requests, so this may
not be very useful to you if you have multiple shards.
Alternatively, you can look into distributed tracing[3].


[1]
https://solr.apache.org/guide/solr/latest/deployment-guide/configuring-logging.html#request-logging
[2]
https://wiki.eclipse.org/Jetty/Tutorial/RequestLog#Configuring_time_format_in_CustomRequestLog
[3]
https://solr.apache.org/guide/solr/latest/deployment-guide/distributed-tracing.html

On Thu, Jan 12, 2023 at 11:37 AM Markus Jelsma <markus.jel...@openindex.io>
wrote:

> Hello,
>
> You can extend SearchHandler and implement handleRequestBody(). There is
> a SolrQueryResponse object that you can use to add HTTP headers, or add
> fields to the log.
>
> Regards,
> Markus
>
> Op do 12 jan. 2023 om 19:32 schreef DAVID MARTIN NIETO <
> dmart...@viewnext.com>:
>
> > Hi
> >
> > I have a similar problem and finally we put a apache server previously to
> > the solr to log fields like you comment. We dont find any way to log on
> > solr or to modify the internal jetty server to it.
> >
> > Kind regards and good luck
> > ________________________________
> > David Martín
> >
> > De: Srijan <shree...@gmail.com>
> > Enviado: jueves, 12 de enero de 2023 20:19
> > Para: solr-user <solr-u...@lucene.apache.org>
> > Asunto: Logging correlation id
> >
> > Hi All,
> >
> > I am looking to log additional info to my Solr log. Specifically, I am
> > looking to log a "correlation-id" provided by my client as part of the
> HTTP
> > header field "x-correlation-id" and put that in my log to relate various
> > client sessions and their actions with Solr. Is there a codeless way of
> > doing this? Has anyone done something similar?
> >
> > Thanks,
> > Srijan
> >
>

Reply via email to