You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Srijan <sh...@gmail.com> on 2023/01/12 19:19:27 UTC

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

Re: Logging correlation id

Posted by Jan Høydahl <ja...@cominvent.com>.
[| [Distributed Tracing :: Apache Solr Reference
Guide](https://solr.apache.org/guide/solr/latest/deployment-guide/distributed-
tracing.html)[solr.apache.org](https://solr.apache.org/guide/solr/latest/deployment-
guide/distributed-tracing.html)|
[![favicon.ico](cid:9688BE76-38B3-4B1F-BCBC-B82782A7F994)](https://solr.apache.org/guide/solr/latest/deployment-
guide/distributed-tracing.html)  
---|---  
](https://solr.apache.org/guide/solr/latest/deployment-guide/distributed-
tracing.html)

  
  

Jan Høydahl

  

> 16\. jan. 2023 kl. 09:28 skrev DAVID MARTIN NIETO <dm...@viewnext.com>:  
>  
>

>   
> Where is that?  
> enabling tracing, (header trace-parent)  
>  
> Thanks.  
>  
>  
> ________________________________  
> De: Jan Høydahl <ja...@cominvent.com>  
> Enviado: viernes, 13 de enero de 2023 16:42  
> Para: users@solr.apache.org <us...@solr.apache.org>  
> Asunto: Re: Logging correlation id  
>  
> Have you considered enabling tracing, (header trace-parent) and get that Id
> added to the logs?  
>  
> Jan Høydahl  
>  
>
>

>> 13\. jan. 2023 kl. 02:42 skrev Shawn Heisey <ap...@elyograg.org>:  
>
>

>>  
>
>

>> On 1/12/23 12:19, Srijan wrote:  
>
>

>> > 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?  
>
>

>>  
>
>

>> If you make it a URL parameter instead of a header, Solr will log it
automatically.  
>
>

>>  
>
>

>> Arbitrary URL parameters that do not match anything Solr expects tend to be
ignored, so it is a good way to log something that doesn't affect Solr.  
>
>

>>  
>
>

>> If it must be a header, then you're going to need to write some custom code
as suggesteed by Markus.  
>
>

>>  
>
>

>> Thanks,  
>
>

>> Shawn  
>


RE: Logging correlation id

Posted by DAVID MARTIN NIETO <dm...@viewnext.com>.
Where is that?
enabling tracing, (header trace-parent)

Thanks.


________________________________
De: Jan Høydahl <ja...@cominvent.com>
Enviado: viernes, 13 de enero de 2023 16:42
Para: users@solr.apache.org <us...@solr.apache.org>
Asunto: Re: Logging correlation id

Have you considered enabling tracing, (header trace-parent) and get that Id added to the logs?

Jan Høydahl

> 13. jan. 2023 kl. 02:42 skrev Shawn Heisey <ap...@elyograg.org>:
>
> On 1/12/23 12:19, Srijan wrote:
>> 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?
>
> If you make it a URL parameter instead of a header, Solr will log it automatically.
>
> Arbitrary URL parameters that do not match anything Solr expects tend to be ignored, so it is a good way to log something that doesn't affect Solr.
>
> If it must be a header, then you're going to need to write some custom code as suggesteed by Markus.
>
> Thanks,
> Shawn

Re: Logging correlation id

Posted by Jan Høydahl <ja...@cominvent.com>.
Have you considered enabling tracing, (header trace-parent) and get that Id added to the logs?

Jan Høydahl

> 13. jan. 2023 kl. 02:42 skrev Shawn Heisey <ap...@elyograg.org>:
> 
> On 1/12/23 12:19, Srijan wrote:
>> 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?
> 
> If you make it a URL parameter instead of a header, Solr will log it automatically.
> 
> Arbitrary URL parameters that do not match anything Solr expects tend to be ignored, so it is a good way to log something that doesn't affect Solr.
> 
> If it must be a header, then you're going to need to write some custom code as suggesteed by Markus.
> 
> Thanks,
> Shawn

Re: Logging correlation id

Posted by Shawn Heisey <ap...@elyograg.org>.
On 1/12/23 12:19, Srijan wrote:
> 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?

If you make it a URL parameter instead of a header, Solr will log it 
automatically.

Arbitrary URL parameters that do not match anything Solr expects tend to 
be ignored, so it is a good way to log something that doesn't affect Solr.

If it must be a header, then you're going to need to write some custom 
code as suggesteed by Markus.

Thanks,
Shawn

Re: Logging correlation id

Posted by Tomás Fernández Löbbe <to...@gmail.com>.
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 <ma...@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 <
> dmartinn@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 <sh...@gmail.com>
> > Enviado: jueves, 12 de enero de 2023 20:19
> > Para: solr-user <so...@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
> >
>

Re: Logging correlation id

Posted by Markus Jelsma <ma...@openindex.io>.
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 <
dmartinn@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 <sh...@gmail.com>
> Enviado: jueves, 12 de enero de 2023 20:19
> Para: solr-user <so...@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
>

Re: Logging correlation id

Posted by DAVID MARTIN NIETO <dm...@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 <sh...@gmail.com>
Enviado: jueves, 12 de enero de 2023 20:19
Para: solr-user <so...@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