Skip to content

Commit

Permalink
Set default metricsets for postgresql module (#6761)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano authored and ruflin committed Apr 4, 2018
1 parent 78293a3 commit cf4d911
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 75 deletions.
24 changes: 2 additions & 22 deletions metricbeat/docs/modules/postgresql.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This file is generated! See scripts/docs_collector.py
This module periodically fetches metrics from
https://www.postgresql.org/[PostgreSQL] servers.

Default metricsets are `activity`, `bgwriter` and `database`.

[float]
=== Module-specific configuration notes

Expand Down Expand Up @@ -64,29 +66,7 @@ in <<configuration-metricbeat>>. Here is an example configuration:
----
metricbeat.modules:
- module: postgresql
metricsets:
# Stats about every PostgreSQL database
- database
# Stats about the background writer process's activity
- bgwriter
# Stats about every PostgreSQL process
- activity
period: 10s
# The host must be passed as PostgreSQL URL. Example:
# postgres://localhost:5432?sslmode=disable
# The available parameters are documented here:
# https://godoc.org/github.com/lib/pq#hdr-Connection_String_Parameters
hosts: ["postgres://localhost:5432"]
# Username to use when connecting to PostgreSQL. Empty by default.
#username: user
# Password to use when connecting to PostgreSQL. Empty by default.
#password: pass
----

[float]
Expand Down
1 change: 1 addition & 0 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ metricbeat.modules:

#----------------------------- PostgreSQL Module -----------------------------
- module: postgresql
enabled: true
metricsets:
# Stats about every PostgreSQL database
- database
Expand Down
25 changes: 25 additions & 0 deletions metricbeat/module/postgresql/_meta/config.reference.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- module: postgresql
enabled: true
metricsets:
# Stats about every PostgreSQL database
- database

# Stats about the background writer process's activity
- bgwriter

# Stats about every PostgreSQL process
- activity

period: 10s

# The host must be passed as PostgreSQL URL. Example:
# postgres://localhost:5432?sslmode=disable
# The available parameters are documented here:
# https://godoc.org/github.com/lib/pq#hdr-Connection_String_Parameters
hosts: ["postgres://localhost:5432"]

# Username to use when connecting to PostgreSQL. Empty by default.
#username: user

# Password to use when connecting to PostgreSQL. Empty by default.
#password: pass
22 changes: 0 additions & 22 deletions metricbeat/module/postgresql/_meta/config.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,2 @@
- module: postgresql
metricsets:
# Stats about every PostgreSQL database
- database

# Stats about the background writer process's activity
- bgwriter

# Stats about every PostgreSQL process
- activity

period: 10s

# The host must be passed as PostgreSQL URL. Example:
# postgres://localhost:5432?sslmode=disable
# The available parameters are documented here:
# https://godoc.org/github.com/lib/pq#hdr-Connection_String_Parameters
hosts: ["postgres://localhost:5432"]

# Username to use when connecting to PostgreSQL. Empty by default.
#username: user

# Password to use when connecting to PostgreSQL. Empty by default.
#password: pass
2 changes: 2 additions & 0 deletions metricbeat/module/postgresql/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
This module periodically fetches metrics from
https://www.postgresql.org/[PostgreSQL] servers.

Default metricsets are `activity`, `bgwriter` and `database`.

[float]
=== Module-specific configuration notes

Expand Down
7 changes: 4 additions & 3 deletions metricbeat/module/postgresql/activity/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import (
// init registers the MetricSet with the central registry.
// The New method will be called after the setup of the module and before starting to fetch data
func init() {
if err := mb.Registry.AddMetricSet("postgresql", "activity", New, postgresql.ParseURL); err != nil {
panic(err)
}
mb.Registry.MustAddMetricSet("postgresql", "activity", New,
mb.WithHostParser(postgresql.ParseURL),
mb.DefaultMetricSet(),
)
}

// MetricSet type defines all fields of the Postgresql MetricSet
Expand Down
7 changes: 4 additions & 3 deletions metricbeat/module/postgresql/bgwriter/bgwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import (
// init registers the MetricSet with the central registry.
// The New method will be called after the setup of the module and before starting to fetch data
func init() {
if err := mb.Registry.AddMetricSet("postgresql", "bgwriter", New, postgresql.ParseURL); err != nil {
panic(err)
}
mb.Registry.MustAddMetricSet("postgresql", "bgwriter", New,
mb.WithHostParser(postgresql.ParseURL),
mb.DefaultMetricSet(),
)
}

// MetricSet type defines all fields of the MetricSet
Expand Down
7 changes: 4 additions & 3 deletions metricbeat/module/postgresql/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import (
// init registers the MetricSet with the central registry.
// The New method will be called after the setup of the module and before starting to fetch data
func init() {
if err := mb.Registry.AddMetricSet("postgresql", "database", New, postgresql.ParseURL); err != nil {
panic(err)
}
mb.Registry.MustAddMetricSet("postgresql", "database", New,
mb.WithHostParser(postgresql.ParseURL),
mb.DefaultMetricSet(),
)
}

// MetricSet type defines all fields of the MetricSet
Expand Down
22 changes: 0 additions & 22 deletions metricbeat/modules.d/postgresql.yml.disabled
Original file line number Diff line number Diff line change
@@ -1,24 +1,2 @@
- module: postgresql
metricsets:
# Stats about every PostgreSQL database
- database

# Stats about the background writer process's activity
- bgwriter

# Stats about every PostgreSQL process
- activity

period: 10s

# The host must be passed as PostgreSQL URL. Example:
# postgres://localhost:5432?sslmode=disable
# The available parameters are documented here:
# https://godoc.org/github.com/lib/pq#hdr-Connection_String_Parameters
hosts: ["postgres://localhost:5432"]

# Username to use when connecting to PostgreSQL. Empty by default.
#username: user

# Password to use when connecting to PostgreSQL. Empty by default.
#password: pass

0 comments on commit cf4d911

Please sign in to comment.