Matching statement and duration log lines

Started by Popov Alekseyover 8 years ago2 messagesgeneral
Jump to latest
#1Popov Aleksey
Aleksey.Popov@annalect.omd.ru

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?

#2Bruce Momjian
bruce@momjian.us
In reply to: Popov Aleksey (#1)
Re: [GENERAL] Matching statement and duration log lines

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 +