PGLOG CSVLOG Sample Analysis

Built-in applet for PostgreSQL CSV log sample analysis

PGLOG Analysis & PGLOG Session provide introspection about PostgreSQL csvlog sample (via table pglog.sample on cmdb).

  • PGLOG Analysis: Analysis of csvlog sample on CMDB (focusing on entire log sample).
  • PGLOG Session: Analysis of csvlog sample (focusing on the single session).

There are some handy alias & func sets on the meta node.

Load csvlog from stdin into sample table.

  1. alias pglog="psql service=meta -AXtwc 'TRUNCATE pglog.sample; COPY pglog.sample FROM STDIN CSV;'" # useful alias

Get log from pgsql node.

  1. # default: get pgsql csvlog (localhost @ today)
  2. function catlog(){ # getlog <ip|host> <date:YYYY-MM-DD>
  3. local node=${1-'127.0.0.1'}
  4. local today=$(date '+%Y-%m-%d')
  5. local ds=${2-${today}}
  6. ssh -t "${node}" "sudo cat /pg/data/log/postgresql-${ds}.csv"
  7. }

Combine theme to fetch and load csvlog sample.

  1. catlog | pglog # get local (metadb) today's log
  2. catlog node-1 '2021-07-15' | pglog # get node-1's csvlog @ 2021-07-15
  1. catlog [node=localhost] [date=today] # Print PG CSV log to stdout
  2. pglog # ingest pgcsv log into sample table
  3. pglog12 # ingest pg 12 log
  4. pglog13 # ingest pg 13 log
  5. pglog14 # ingest pg 14 log (default)
  6. catlog | pglog # pour log of current node
  7. catlog node-1 '2021-07-15' | pglog # analysis node-1 on 2021-07-15j

PGLOG Analysis - 图1

Last modified 2022-06-18: v1.5.1 (8de4142)