Skip to content

Commit f029a52

Browse files
authored
Fix pipeline when user.name and postgresql.log.database with brackets (#3812)
1 parent 9733bff commit f029a52

File tree

5 files changed

+58
-8
lines changed

5 files changed

+58
-8
lines changed

packages/postgresql/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
- version: "1.4.1"
2+
changes:
3+
- description: Fix pipeline when user.name and postgresql.log.database with brackets
4+
type: bugfix
5+
link: https://github.com/elastic/integrations/pull/3812
16
- version: "1.4.0"
27
changes:
38
- description: Add support for AWS postgresql standard log format

packages/postgresql/data_stream/log/_dev/test/pipeline/test-postgresql-aws.log

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
d.datctype as "Ctype",
1010
pg_catalog.array_to_string(d.datacl, E'\n') AS "Access privileges"
1111
FROM pg_catalog.pg_database d
12-
ORDER BY 1;
12+
ORDER BY 1;
13+
2013-11-05 16:45:14 UTC:172.23.160.69(59176):[unknown]@[unknown]:[9002]:FATAL: unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0

packages/postgresql/data_stream/log/_dev/test/pipeline/test-postgresql-aws.log-expected.json

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"category": [
1010
"database"
1111
],
12-
"ingested": "2022-07-18T21:14:43.737829400Z",
12+
"ingested": "2022-07-22T16:21:07.906562100Z",
1313
"kind": "event",
1414
"original": "2022-06-16 17:58:40 UTC::@:[7770]:LOG: checkpoint starting: time",
1515
"timezone": "UTC",
@@ -42,7 +42,7 @@
4242
"category": [
4343
"database"
4444
],
45-
"ingested": "2022-07-18T21:14:43.737839600Z",
45+
"ingested": "2022-07-22T16:21:07.906572300Z",
4646
"kind": "event",
4747
"original": "2019-03-10 03:54:59 UTC:10.0.0.123(52834):postgres@tstdb:[20175]:ERROR: column \"wrong\" does not exist at character 8",
4848
"timezone": "UTC",
@@ -86,7 +86,7 @@
8686
"category": [
8787
"database"
8888
],
89-
"ingested": "2022-07-18T21:14:43.737847400Z",
89+
"ingested": "2022-07-22T16:21:07.906578400Z",
9090
"kind": "event",
9191
"original": "2022-06-20 22:19:26 UTC:172.23.160.54(33998):accounters@found:[20452]:LOG: statement: INSERT INTO events (user_id, user_principal_id, organization_id, region, cluster_id, invoice_id, trial_id, type, unique_token, data) VALUES (NULL, NULL, NULL, 'aws-eu-west-1', NULL, NULL, NULL, 'accounting', NULL, '{\\\"hostname\\\": \\\"44058ed0088d\\\", \\\"pid\\\": 41441}') RETURNING events.event_id",
9292
"timezone": "UTC",
@@ -131,7 +131,7 @@
131131
"category": [
132132
"database"
133133
],
134-
"ingested": "2022-07-18T21:14:43.737855100Z",
134+
"ingested": "2022-07-22T16:21:07.906585200Z",
135135
"kind": "event",
136136
"original": "2013-11-05 16:51:10 UTC:[local]:master@postgres:[9193]:LOG: statement: SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhparent AND i.inhrelid = '1255' ORDER BY inhseqno;",
137137
"timezone": "UTC",
@@ -175,7 +175,7 @@
175175
"category": [
176176
"database"
177177
],
178-
"ingested": "2022-07-18T21:14:43.737862700Z",
178+
"ingested": "2022-07-22T16:21:07.906592500Z",
179179
"kind": "event",
180180
"original": "2013-11-05 16:45:14 UTC:[local]:master@postgres:[8839]:LOG: statement: SELECT d.datname as \"Name\",\n\t pg_catalog.pg_get_userbyid(d.datdba) as \"Owner\",\n\t pg_catalog.pg_encoding_to_char(d.encoding) as \"Encoding\",\n\t d.datcollate as \"Collate\",\n\t d.datctype as \"Ctype\",\n\t pg_catalog.array_to_string(d.datacl, E'\\n') AS \"Access privileges\"\n\tFROM pg_catalog.pg_database d\n\tORDER BY 1;",
181181
"timezone": "UTC",
@@ -209,6 +209,50 @@
209209
"user": {
210210
"name": "master"
211211
}
212+
},
213+
{
214+
"@timestamp": "2013-11-05T16:45:14.000Z",
215+
"ecs": {
216+
"version": "8.0.0"
217+
},
218+
"event": {
219+
"category": [
220+
"database"
221+
],
222+
"ingested": "2022-07-22T16:21:07.906599400Z",
223+
"kind": "event",
224+
"original": "2013-11-05 16:45:14 UTC:172.23.160.69(59176):[unknown]@[unknown]:[9002]:FATAL: unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0",
225+
"timezone": "UTC",
226+
"type": [
227+
"info"
228+
]
229+
},
230+
"log": {
231+
"level": "FATAL"
232+
},
233+
"message": "unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0",
234+
"postgresql": {
235+
"log": {
236+
"client_addr": "172.23.160.69",
237+
"client_port": 59176,
238+
"database": "unknown",
239+
"timestamp": "2013-11-05 16:45:14 UTC"
240+
}
241+
},
242+
"process": {
243+
"pid": 9002
244+
},
245+
"related": {
246+
"user": [
247+
"unknown"
248+
]
249+
},
250+
"tags": [
251+
"preserve_original_event"
252+
],
253+
"user": {
254+
"name": "unknown"
255+
}
212256
}
213257
]
214258
}

packages/postgresql/data_stream/log/elasticsearch/ingest_pipeline/pipeline-aws-log.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ processors:
55
field: raw_message
66
ignore_missing: true
77
patterns:
8-
- '(%{DATA:postgresql.log.client_addr}\(%{NUMBER:postgresql.log.client_port:int}\)|\[%{DATA:postgresql.log.client_addr}\])?:%{USERNAME:user.name}?@%{POSTGRESQL_DB_NAME:postgresql.log.database}?:(\[%{NUMBER:process.pid:long}\])?:%{WORD:log.level}: (%{POSTGRESQL_QUERY_STEP}: %{GREEDYDATA:postgresql.log.query}| %{GREEDYDATA:message}|%{GREEDYDATA:message})'
8+
- '(%{DATA:postgresql.log.client_addr}\(%{NUMBER:postgresql.log.client_port:int}\)|\[%{DATA:postgresql.log.client_addr}\])?:(%{USERNAME:user.name}?@%{POSTGRESQL_DB_NAME:postgresql.log.database}?|\[%{USERNAME:user.name}?\]@\[%{POSTGRESQL_DB_NAME:postgresql.log.database}?\]):(\[%{NUMBER:process.pid:long}\])?:%{WORD:log.level}: (%{POSTGRESQL_QUERY_STEP}: %{GREEDYDATA:postgresql.log.query}| %{GREEDYDATA:message}|%{GREEDYDATA:message})'
99
pattern_definitions:
1010
GREEDYDATA: '(.|\r|\n)*'
1111
POSTGRESQL_DB_NAME: '[a-zA-Z0-9_]+[a-zA-Z0-9_\$]*'

packages/postgresql/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
format_version: 1.0.0
22
name: postgresql
33
title: PostgreSQL
4-
version: 1.4.0
4+
version: 1.4.1
55
license: basic
66
description: Collect logs and metrics from PostgreSQL servers with Elastic Agent.
77
type: integration

0 commit comments

Comments
 (0)