darold / pgbadger

A fast PostgreSQL Log Analyzer
http://pgbadger.darold.net/
PostgreSQL License
3.45k stars 348 forks source link

pgbadger can't parse CSV format auto_explain plan #825

Open zxwsbg opened 2 months ago

zxwsbg commented 2 months ago

I set following params:

log_destination = 'csvlog'
log_filename = 'postgresql-%d-%H.log'
logging_collector = 'on'
auto_explain.log_min_duration=0
auto_explain.log_analyze=true
auto_explain.log_format='text'
shared_preload_libraries='auto_explain'

And I found pgbadger can't parse CSV format LOG pretyfully.

image

When I change log_destination to 'stderr', pgbadger can parse LOG correctly.

image
darold commented 2 months ago

Please can you post a line from your csvlog with a query and auto_explain output ?

zxwsbg commented 2 months ago

Please can you post a line from your csvlog with a query and auto_explain output ?

csv output :

2024-05-15 11:54:08.146 UTC,"postgres","postgres",13215,"[local]",6644a260.339f,1,"SELECT",2024-05-15 11:54:08 UTC,3/2,0,LOG,00000,"duration: 52.114 ms  plan:
Query Text: select * from t where a=32;
Gather  (cost=1000.00..10633.43 rows=1 width=4) (actual time=0.270..52.105 rows=1 loops=1)
  Workers Planned: 2
  Workers Launched: 2
  ->  Parallel Seq Scan on t  (cost=0.00..9633.33 rows=1 width=4) (actual time=31.724..48.541 rows=0 loops=3)
        Filter: (a = 32)
        Rows Removed by Filter: 333333",,,,,,,,"explain_ExecutorEnd, auto_explain.c:422","psql","client backend",,0

And my stderr output:

2024-05-15 11:56:33.470 UTC [15449] LOG:  00000: duration: 51.182 ms  plan:
        Query Text: select * from t where a=32;
        Gather  (cost=1000.00..10633.43 rows=1 width=4) (actual time=0.265..51.173 rows=1 loops=1)
          Workers Planned: 2
          Workers Launched: 2
          ->  Parallel Seq Scan on t  (cost=0.00..9633.33 rows=1 width=4) (actual time=31.170..47.669 rows=0 loops=3)
                Filter: (a = 32)
                Rows Removed by Filter: 333333

My command is

pgbadger -q postgresql-15-11.csv(log) -o a.html -j 8