Saturday, April 6, 2024

.::: Convert pgaudit & pgauditlogtofile log insert into table in PostgreSQL EDB :::.

 continue from http://teguhth.blogspot.com/2024/02/enable-pgaudit-pgauditlogtofile-in.html

1. Create table pgaudit_log

CREATE TABLE pgaudit_log (
log_time text,
user_name text,
dbname text,
process_id text,
connection_from text,
session_id text,
session_line_num text,
command_tag text,
session_start_time text,
virtual_transaction_id text,
transaction_id text,
error_severity text,
sql_state_code text,
message text,
detail text,
hint text,
internal_query text,
internal_query_pos text,
context text,
query text,
query_pos text,
location text,
application_name text,
backend_type text,
leader_pid text,
query_id text,
custom_1 text,
custom_2 text,
custom_3 text,
console text
);

 
2. Check contain pgaudit log
 


3. run copy to table

delete from pgaudit_log;
COPY pgaudit_log FROM '/var/lib/pgsql/16/data/log/pgaudit-06.log' DELIMITER ',' CSV;
select * from pgaudit_log;


4. Check Table pgaudit_log


 

No comments:

Post a Comment

Popular Posts