At work we are consuming the PostgreSQL CSV log instead of plain log. This poses some advantages, like a better formatted input file, stable format, and easy to turn it on.
To achieve it, we are using the filebeat processors, first decoding a multiline CSV then break each field.
Now I'm looking to incorporate this as a filebeat code. Is someone working on anything similar? Should I look at beats/filebeat/module and replicate this structure?
The default module of filebeat for postgresql export only some fields from the stderr default log format.
You will need to map all csv fields of postgresql log format to the ESC schema :
field
type
ecs mapping
example
log_time
timestamp(3) with time zone
postgresql.log.timestamp
2020-12-27 08:43:50.674 PST
user_name
text
user.name
postgres
database_name
text
postgresql.log.database
postgres
process_id
integer
process.pid
9004
connection_from
text
?
::1:53881
session_id
text
?
5fe8b9c6.232c
session_line_num
bigint
?
1
command_tag
text
?
authentication
session_start_time
timestamp(3) with time zone
?
2020-12-27 08:43:50 PST
virtual_transaction_id
text
?
9/57
transaction_id
bigint
?
0
error_severity
text
log.level
FATAL
sql_state_code
text
postgresql.log.error.code
28000
message
text
log.message
no pg_hba.conf entry for host "::1", user "postgres", database "postgres", SSL off
You can write your own module for this and send it as a PR
Something like this may help
Note that when you write your own module in beat, you use mostly ingest processor of elasticsearch instead of beat processors
When the beat is runned for the first time, the ingest pipeline ($BEAT_HOME/modules/${MODULE_NAME}/${STREAM_TYPE}/ingest/pipeline.yml) is loaded into elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.