Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metricbeat/module/postgresql: Add PostgreSQL Replication metricset #35562

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
25e6aff
Add PostgresSQL Replication metricset
zxcSora May 24, 2023
a3a716b
Fixes after review
zxcSora May 31, 2023
c098a05
impove docs
zxcSora May 31, 2023
6571445
add Uint parse
zxcSora Jun 1, 2023
55d70a1
Change Uint size, fix comment
zxcSora Jun 6, 2023
1d7027d
Change PG query
zxcSora Jun 6, 2023
9e2c121
Merge branch 'main' into main
shmsr Jul 3, 2023
8d2d0f4
Merge branch 'main' into main
shmsr Jul 5, 2023
93eaee6
Merge branch 'main' into main
shmsr Jul 7, 2023
50e66da
update changelog, fix nitpicks
zxcSora Jul 10, 2023
f3143d8
Fix recovering from invalid output configuration under Elastic-Agent …
belimawr Jul 7, 2023
4838145
chore: Updated to content "" in file "testing/environments/snapshot.y…
apmmachine Jul 10, 2023
eebc5ae
Merge branch 'main' into main
shmsr Jul 11, 2023
300b3e3
Update CHANGELOG.next.asciidoc
zxcSora Jul 11, 2023
beec498
Merge branch 'main' into main
ishleenk17 Jul 14, 2023
ae6cc32
Merge branch 'main' into main
zxcSora Jul 17, 2023
eec0bd2
Merge branch 'main' into main
zxcSora Jul 20, 2023
4a84a0f
Merge branch 'main' into main
zxcSora Jul 21, 2023
9d1e267
Merge branch 'main' into main
zxcSora Jul 26, 2023
f33bc75
Merge branch 'main' into main
zxcSora Jul 27, 2023
0d1c619
Merge branch 'main' into main
zxcSora Jul 28, 2023
ee7ca86
Merge branch 'main' into main
zxcSora Jul 31, 2023
bf6179b
Merge branch 'main' into main
zxcSora Aug 1, 2023
55f3359
Merge branch 'main' into main
zxcSora Aug 1, 2023
dd53fa4
Merge branch 'main' into main
zxcSora Sep 19, 2023
3adfd57
fix panic
zxcSora Sep 19, 2023
659bb76
fix copy-paste misstake
zxcSora Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -56304,6 +56304,193 @@ type: date

--

[float]
=== replication

One row per replication, showing database replication statistics. Collected by querying pg_stat_database



*`postgresql.replication.write_lag`*::
+
--
Elapsed time during committed WALs from primary to the replica.
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.state`*::
+
--
WAL sender state.
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: keyword

--

*`postgresql.replication.sync_priority`*::
+
--
Priority of replica server being chosen as synchronous replica.
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.backend_start`*::
+
--
Start time when replica connected to primary.
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.replay_lag`*::
+
--
Elapsed time during committed WALs from primary to the replica. Fully committed in replica node
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.flush_lag`*::
+
--
Elapsed time during committed WALs from primary to the replica. WAL's has already been flushed but not yet applied.
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.pid`*::
+
--
Process id of walsender process


type: long

--

*`postgresql.replication.client.address`*::
+
--
Address of replica/streaming replication


type: long

--

*`postgresql.replication.client.port`*::
+
--
Port of replica/streaming replication


type: long

--

*`postgresql.replication.client.hostname`*::
+
--
Hostname of replica/streaming replication
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.replay_lsn`*::
+
--
Last transaction flush on disk at replica.
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.user.name`*::
+
--
Name of user which is used for Streaming replication
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.user.id`*::
+
--
ID of user which is used for Streaming replication
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.sync_state`*::
+
--
Sync State of replica.
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.flush_lsn`*::
+
--
Last transaction flush on disk at replica.


type: long

--

*`postgresql.replication.application_name`*::
+
--
Number of queries canceled due to conflicts with recovery in this database.
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.write_lsn`*::
+
--
Last transaction written on disk at replica.
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

*`postgresql.replication.sent_lsn`*::
+
--
Last transaction location sent to replica
zxcSora marked this conversation as resolved.
Show resolved Hide resolved


type: long

--

[float]
=== statement

Expand Down
7 changes: 7 additions & 0 deletions metricbeat/docs/modules/postgresql.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ metricbeat.modules:
# Stats about every PostgreSQL process
- activity

# Stats about every PostgreSQL replication process
- replication

# Stats about every statement executed in the server. It requires the
# `pg_stats_statement` library to be configured in the server.
#- statement
Expand Down Expand Up @@ -126,6 +129,8 @@ The following metricsets are available:

* <<metricbeat-metricset-postgresql-database,database>>

* <<metricbeat-metricset-postgresql-replication,replication>>

* <<metricbeat-metricset-postgresql-statement,statement>>

include::postgresql/activity.asciidoc[]
Expand All @@ -134,6 +139,8 @@ include::postgresql/bgwriter.asciidoc[]

include::postgresql/database.asciidoc[]

include::postgresql/replication.asciidoc[]

include::postgresql/statement.asciidoc[]

:edit_url!:
27 changes: 27 additions & 0 deletions metricbeat/docs/modules/postgresql/replication.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
////
This file is generated! See scripts/mage/docs_collector.go
////
:edit_url: https://github.com/elastic/beats/edit/main/metricbeat/module/postgresql/replication/_meta/docs.asciidoc


[[metricbeat-metricset-postgresql-replication]]
=== PostgreSQL replication metricset

include::../../../module/postgresql/replication/_meta/docs.asciidoc[]

This is a default metricset. If the host module is unconfigured, this metricset is enabled by default.

:edit_url:

==== Fields

For a description of each field in the metricset, see the
<<exported-fields-postgresql,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/postgresql/replication/_meta/data.json[]
----
:edit_url!:
3 changes: 2 additions & 1 deletion metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,10 @@ This file is generated! See scripts/mage/docs_collector.go
.2+| .2+| |<<metricbeat-metricset-php_fpm-pool,pool>>
|<<metricbeat-metricset-php_fpm-process,process>>
|<<metricbeat-module-postgresql,PostgreSQL>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.4+| .4+| |<<metricbeat-metricset-postgresql-activity,activity>>
.5+| .5+| |<<metricbeat-metricset-postgresql-activity,activity>>
|<<metricbeat-metricset-postgresql-bgwriter,bgwriter>>
|<<metricbeat-metricset-postgresql-database,database>>
|<<metricbeat-metricset-postgresql-replication,replication>>
|<<metricbeat-metricset-postgresql-statement,statement>>
|<<metricbeat-module-prometheus,Prometheus>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.3+| .3+| |<<metricbeat-metricset-prometheus-collector,collector>>
Expand Down
1 change: 1 addition & 0 deletions metricbeat/include/list_common.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,9 @@ metricbeat.modules:
# Stats about every PostgreSQL process
- activity

# Stats about every PostgreSQL replication process
- replication

# Stats about every statement executed in the server. It requires the
# `pg_stats_statement` library to be configured in the server.
#- statement
Expand Down
3 changes: 3 additions & 0 deletions metricbeat/module/postgresql/_meta/config.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# Stats about every PostgreSQL process
- activity

# Stats about every PostgreSQL replication process
- replication

# Stats about every statement executed in the server. It requires the
# `pg_stats_statement` library to be configured in the server.
#- statement
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/postgresql/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions metricbeat/module/postgresql/replication/_meta/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"@timestamp": "2023-05-24T12:22:59.233Z",
"event": {
"dataset": "postgresql.replication",
"duration": 115000,
"module": "postgresql"
},
"metricset": {
"name": "replication",
"period": 10000
},
"postgresql": {
"replication": {
"write_lag": "",
"state": "streaming",
"sync_priority": 0,
"backend_start": "2023-05-23T17:01:53.697Z",
"replay_lag": "",
"flush_lag": "",
"pid": 2516780,
"client": {
"address": "192.168.128.2",
"port": 46594,
"hostname": ""
},
"replay_lsn": "A0/60003558",
"user": {
"name": "replicator",
"id": 16442
},
"sync_state": "async",
"flush_lsn": "A0/60003558",
"application_name": "walreceiver",
"write_lsn": "A0/60003558",
"sent_lsn": "A0/60003558"
}
},
"service": {
"address": "postgres://localhost:5432/postgres?connect_timeout=10",
"type": "postgresql"
}
}
42 changes: 42 additions & 0 deletions metricbeat/module/postgresql/replication/_meta/data_shared.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"@timestamp": "2023-05-24T12:22:59.233Z",
"event": {
"dataset": "postgresql.replication",
"duration": 115000,
"module": "postgresql"
},
"metricset": {
"name": "replication",
"period": 10000
},
"postgresql": {
"replication": {
"write_lag": "",
"state": "",
"sync_priority": 0,
"backend_start": "",
"replay_lag": "",
"flush_lag": "",
"pid": 0,
"client": {
"address": "",
"port": 0,
"hostname": ""
},
"replay_lsn": "",
"user": {
"name": "",
"id": 0
},
"sync_state": "",
"flush_lsn": "",
"application_name": "",
"write_lsn": "",
"sent_lsn": ""
}
},
"service": {
"address": "postgres://localhost:5432/postgres?connect_timeout=10",
"type": "postgresql"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the `replication` metricset of the PostgreSQL module.
Loading