Hi, I'm having trouble generating the GROK of AWS logs from the same elasticsearch configuration, as well as from the filebeat.yml file.
# ============================== Filebeat inputs ===============================
filebeat.inputs:
- type: aws-cloudwatch
log_group_arn: arn:aws:logs:URL/postgresql:*
scan_frequency: 1m
#credential_profile_name: elastic-beats
access_key_id: 'key'
secret_access_key: 'access_key'
start_position: end
I have the console output to be able to visualize
# ================================== Outputs ===================================
output.console:
pretty: true
In the section of the processors
# ================================= Processors =================================
processors:
grok:
match:
message: '%{TIMESTAMP_ISO8601:awscloudwatch.postgresql.log_timestamp}.*:%{IP:awscloudwatch.postgresql.log_client_addr}.*\(%{DATA:awscloudwatch.postgresql.log_port}\):%{DATA:awscloudwatch.postgresql.log_user}@%{GREEDYDATA:awscloudwatch.postgresql.log_database}.*:\[%{DATA:wscloudwatch.postgresql.log_core_id}}\]:%{DATA:awscloudwatch.postgresql.log_level}\:*SESSION,%{NUMBER:awscloudwatch.postgresql.log_session_id}.*WRITE,%{DATA:awscloudwatch.postgresql.log_command_tag},,,\\%{GREEDYDATA:awscloudwatch.postgresql.log_query_name}.*'
grok:
match:
message: '%{TIMESTAMP_ISO8601:awscloudwatch.postgresql.log_timestamp}.*:%{IP:awscloudwatch.postgresql.log_client_addr}.*\(%{DATA:awscloudwatch.postgresql.log_port}\):%{DATA:awscloudwatch.postgresql.log_user}@%{GREEDYDATA:awscloudwatch.postgresql.log_database}.*:\[%{DATA:awscloudwatch.postgresql.log_core_id}\]:%{DATA:awscloudwatch.postgresql.log_level}\:.*\nSESSION,%{NUMBER:awscloudwatch.postgresql.log_session_id}.*WRITE,%{DATA:awscloudwatch.postgresql.log_command_tag},,,\\%{GREEDYDATA:awscloudwatch.postgresql.log_query_name}.*'
grok:
match:
message: '%{TIMESTAMP_ISO8601:awscloudwatch.postgresql.log_timestamp}.*:%{IP:awscloudwatch.postgresql.log_client_addr}.*\(%{DATA:awscloudwatch.postgresql.log_port}\):%{DATA:awscloudwatch.postgresql.log_user}@%{GREEDYDATA:awscloudwatch.postgresql.log_database}.*:\[%{DATA:awscloudwatch.postgresql.log_core_id}\]:%{DATA:awscloudwatch.postgresql.log_level}\:.*SESSION,%{NUMBER:awscloudwatch.postgresql.log_session_id}.*WRITE,%{WORD:awscloudwatch.postgresql.log_command_tag}.*,,,(?<awscloudwatch.postgresql.log_query_name>(.|\r|\n)*)'
The example log
2023-02-21 19:01:11 UTC:127.0.0.0(00000):user@Data_base_db:[12345]:LOG: AUDIT: SESSION,1,1,WRITE,UPDATE,,,\"UPDATE \"\"data_base_name\"\" SET \"\"created\"\" = '2023-02-21T20:01:11.584950+00:00'::timestamptz WHERE \"\"data_base_name\"\".\"\"key\"\" = 'fffffffffffffffffffffffffffffffffffffffff'\",<not logged>