Thread: [GENERAL] Matching statement and duration log lines

[GENERAL] Matching statement and duration log lines

From
Popov Aleksey
Date:

Hello!

I am sending PG logs to Elasticsearch and want to merge a line with statement and a line with duration into one document.
Having a statement line and a duration line, can I assume that if a session ids (%c) of these lines match,
and numbers of log lines (%l) are consecutive, then the duration line belongs to statement line?

Re: [GENERAL] Matching statement and duration log lines

From
Bruce Momjian
Date:
On Mon, Oct 23, 2017 at 01:06:07PM +0000, Popov Aleksey wrote:
> Hello!
> 
> I am sending PG logs to Elasticsearch and want to merge a line with statement
> and a line with duration into one document.
> Having a statement line and a duration line, can I assume that if a session ids
> (%c) of these lines match,
> and numbers of log lines (%l) are consecutive, then the duration line belongs
> to statement line?

Very late reply here, but setting log_min_duration_statement to zero
will give you those on one line, but the statement will only be output
when it completes, rather than when it starts, which is what
log_statement does.

And, yes, using %c to match up lines will work too.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +