Skip to content

Commit ad1a9dc

Browse files
authored
[Postgresql] [Bugfix] create new field query_id field to replace query field as dimension field (#8248)
The change helps to prevent the errors of storing data in ES when the query field in pg_stat_activity table exceeds 1024 byte length. The length of the values stored in the query field can extend beyond 1024 bytes, which is the limit of dimension field length after a limit override
1 parent 90ce86e commit ad1a9dc

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

packages/postgresql/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "1.17.1"
3+
changes:
4+
- description: Replaced `postgresql.activity.query` with `postgresql.activity.query_id` as TSDS dimension field to support query length greater than 1024.
5+
type: bugfix
6+
link: https://github.com/elastic/integrations/pull/8248
27
- version: 1.17.0
38
changes:
49
- description: Update the package format_version to 3.0.0.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
description: Pipeline for processing postgres activity datastream
3+
processors:
4+
- fingerprint:
5+
fields: ["postgresql.activity.query"]
6+
target_field: postgresql.activity.query_id
7+
ignore_failure: true
8+
ignore_missing: true

packages/postgresql/data_stream/activity/fields/fields.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@
9999
* disabled: This state is reported if track_activities is disabled in this backend.
100100
- name: query
101101
type: keyword
102-
dimension: true
103-
# Reason to add as a dimension field: pg_stat_bgwriter and pg_stat_database returns same fields. The length of the query is very small and hence content hashing is not needed.
104102
description: |
105103
Text of this backend's most recent query. If state is active this field shows the currently executing query. In all other states, it shows the last query that was executed.
104+
- name: query_id
105+
type: keyword
106+
dimension: true
107+
description: |
108+
Unique ID representing the query executed

packages/postgresql/docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ An example event for `activity` looks as following:
291291
| postgresql.activity.database.oid | OID of the database this backend is connected to. | long |
292292
| postgresql.activity.pid | Process ID of this backend. | long |
293293
| postgresql.activity.query | Text of this backend's most recent query. If state is active this field shows the currently executing query. In all other states, it shows the last query that was executed. | keyword |
294+
| postgresql.activity.query_id | Unique ID representing the query executed | keyword |
294295
| postgresql.activity.query_start | Time when the currently active query was started, or if state is not active, when the last query was started. | date |
295296
| postgresql.activity.state | Current overall state of this backend. Possible values are: \* active: The backend is executing a query. \* idle: The backend is waiting for a new client command. \* idle in transaction: The backend is in a transaction, but is not currently executing a query. \* idle in transaction (aborted): This state is similar to idle in transaction, except one of the statements in the transaction caused an error. \* fastpath function call: The backend is executing a fast-path function. \* disabled: This state is reported if track_activities is disabled in this backend. | keyword |
296297
| postgresql.activity.state_change | Time when the state was last changed. | date |

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: "3.0.0"
22
name: postgresql
33
title: PostgreSQL
4-
version: "1.17.0"
4+
version: "1.17.1"
55
description: Collect logs and metrics from PostgreSQL servers with Elastic Agent.
66
type: integration
77
categories:

0 commit comments

Comments
 (0)