Skip to content

Commit 4516827

Browse files
authored
Make RDS regex more resilient (DataDog#22835)
* Make RDS regex more verbose It was missing a group and actually failed to match anything in prod. Because I overrode the org2 pattern in staging (and prod), I didn't notice I forgot to update this generally until we started testing other orgs. This doesn't break existing uses of this pattern as they aren't matching anything at all to begin with. * Add test * Add second test * Fix test * Fix second test
1 parent 730dd5f commit 4516827

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

postgres/assets/logs/postgresql.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ pipeline:
7272
suggested_format %{_prefix} %{_severity}:\s+(%{regex("statement:")}\s+%{_raw_query}|%{data:msg})
7373
7474
#See RDS documentation for more data-rich format
75-
enhanced_rds_with_duration %{_timestamp_ms}:%{_client_ip}\(%{port:network.client.port:integer}\):%{_user}@%{_database}:\[%{_proc_id}\]:%{integer:session_lineno}:%{notSpace:sql_state}:%{_betimestamp}:%{regex("[^:]+"):postgres.vxid}:%{regex("[^:]+"):postgres.xid}:%{regex("[^:]+"):postgres.session_id}:(%{regex("[^:]+"):postgres.appname})?:%{_severity}:\s+duration:\s+%{_duration}\s+ms\s+(%{regex("statement:")}\s+%{_raw_query}|%{data:msg})
75+
enhanced_rds_with_duration %{_timestamp_ms}:%{_client_ip}\(%{port:network.client.port:integer}\):%{_user}@%{_database}:\[%{_proc_id}\]:%{integer:session_lineno}:%{notSpace:sql_state}:%{_betimestamp}:%{regex("[^:]+"):postgres.vxid}:%{regex("[^:]+"):postgres.xid}:%{regex("[^:]+"):postgres.session_id}:(%{regex("[^:]+"):postgres.appname})?:%{_severity}:\s*(%{integer}:\s*)?duration:\s+%{_duration}\s+ms\s+(%{regex("statement:")}\s+%{_raw_query}|%{data:msg})
7676
77-
enhanced_rds %{_timestamp_ms}:%{_client_ip}\(%{port:network.client.port:integer}\):%{_user}@%{_database}:\[%{_proc_id}\]:%{integer:session_lineno}:%{notSpace:sql_state}:%{_betimestamp}:%{regex("[^:]+"):postgres.vxid}:%{regex("[^:]+"):postgres.xid}:%{regex("[^:]+"):postgres.session_id}:(%{regex("[^:]+"):postgres.appname})?:%{_severity}:\s+(%{regex("statement:")}\s+%{_raw_query}|%{data:msg})
77+
enhanced_rds %{_timestamp_ms}:(%{_client_ip}\(%{port:network.client.port:integer}\))?:(%{_user})?@(%{_database})?:\[%{_proc_id}\]:%{integer:session_lineno}:%{notSpace:sql_state}:%{_betimestamp}:%{regex("[^:]+"):postgres.vxid}:%{regex("[^:]+"):postgres.xid}:%{regex("[^:]+"):postgres.session_id}:(%{regex("[^:]+"):postgres.appname}:)?%{_severity}:\s*(%{integer}:\s*)?(%{regex("statement:")}\s+%{_raw_query}|%{data:msg})
7878
7979
default_format (%{_timestamp}|%{_timestamp_ms} \[%{_proc_id}])\s+%{_severity}:\s+(%{regex("statement:")}\s+%{_raw_query}|%{data:msg})
8080

postgres/assets/logs/postgresql_tests.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,52 @@ tests:
118118
- "source:LOGS_SOURCE"
119119
- "db:postgres"
120120
timestamp: 1758047205429
121+
-
122+
sample: "2025-11-19 18:27:10.640 UTC:10.198.137.95(54414):service_catalog_rw@service_catalog:[194370]:4:00000:2025-11-19 18:21:43 UTC:15/174689:276953619:691e0ab7.2f742:PostgreSQL JDBC Driver:LOG: duration: 1626.107 ms plan: {}"
123+
result:
124+
custom:
125+
db:
126+
backend_start: 1763576503000
127+
date: 1763576830640
128+
instance: "service_catalog"
129+
severity: "LOG"
130+
user: "service_catalog_rw"
131+
duration: 1.626107E9
132+
network:
133+
client:
134+
ip: "10.198.137.95"
135+
port: 54414
136+
postgres:
137+
appname: "PostgreSQL JDBC Driver"
138+
proc_id: "194370"
139+
session_id: "691e0ab7.2f742"
140+
vxid: "15/174689"
141+
xid: "276953619"
142+
session_lineno: 4
143+
sql_state: "00000"
144+
message: "plan: {}"
145+
status: "info"
146+
tags:
147+
- "source:LOGS_SOURCE"
148+
- "db:service_catalog"
149+
timestamp: 1763576830640
150+
-
151+
sample: "2025-12-03 19:59:40.415 UTC::@:[1670514]:1:00000:2025-12-03 19:59:26 UTC:20/120887:0:6930969e.197d72:LOG: automatic vacuum of table \"dm_v0.stream_router.kv_shadow_entei\": index scans: 1"
152+
result:
153+
custom:
154+
db:
155+
backend_start: 1764791966000
156+
date: 1764791980415
157+
severity: "LOG"
158+
postgres:
159+
proc_id: "1670514"
160+
session_id: "6930969e.197d72"
161+
vxid: "20/120887"
162+
xid: "0"
163+
session_lineno: 1
164+
sql_state: "00000"
165+
message: "automatic vacuum of table \"dm_v0.stream_router.kv_shadow_entei\": index scans: 1"
166+
status: "info"
167+
tags:
168+
- "source:LOGS_SOURCE"
169+
timestamp: 1764791980415

0 commit comments

Comments
 (0)