mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-02-25 23:11:16 +00:00
Fix up collector registration (#812)
Use const definitions to make collector registration consistent. * Use collector subsystem name consistently. * Fix up replication metric name unit. Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
parent
3e585c4061
commit
99828de70a
@ -21,8 +21,10 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const databaseSubsystem = "database"
|
||||
|
||||
func init() {
|
||||
registerCollector("database", defaultEnabled, NewPGDatabaseCollector)
|
||||
registerCollector(databaseSubsystem, defaultEnabled, NewPGDatabaseCollector)
|
||||
}
|
||||
|
||||
type PGDatabaseCollector struct {
|
||||
@ -43,7 +45,11 @@ func NewPGDatabaseCollector(config collectorConfig) (Collector, error) {
|
||||
|
||||
var (
|
||||
pgDatabaseSizeDesc = prometheus.NewDesc(
|
||||
"pg_database_size_bytes",
|
||||
prometheus.BuildFQName(
|
||||
namespace,
|
||||
databaseSubsystem,
|
||||
"size_bytes",
|
||||
),
|
||||
"Disk space used by the database",
|
||||
[]string{"datname"}, nil,
|
||||
)
|
||||
|
@ -20,8 +20,10 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const postmasterSubsystem = "postmaster"
|
||||
|
||||
func init() {
|
||||
registerCollector("postmaster", defaultEnabled, NewPGPostmasterCollector)
|
||||
registerCollector(postmasterSubsystem, defaultEnabled, NewPGPostmasterCollector)
|
||||
}
|
||||
|
||||
type PGPostmasterCollector struct {
|
||||
@ -33,7 +35,11 @@ func NewPGPostmasterCollector(collectorConfig) (Collector, error) {
|
||||
|
||||
var (
|
||||
pgPostMasterStartTimeSeconds = prometheus.NewDesc(
|
||||
"pg_postmaster_start_time_seconds",
|
||||
prometheus.BuildFQName(
|
||||
namespace,
|
||||
postmasterSubsystem,
|
||||
"start_time_seconds",
|
||||
),
|
||||
"Time at which postmaster started",
|
||||
[]string{}, nil,
|
||||
)
|
||||
|
@ -21,16 +21,16 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const processIdleSubsystem = "process_idle"
|
||||
|
||||
func init() {
|
||||
registerCollector("statements", defaultEnabled, NewPGProcessIdleCollector)
|
||||
registerCollector(processIdleSubsystem, defaultEnabled, NewPGProcessIdleCollector)
|
||||
}
|
||||
|
||||
type PGProcessIdleCollector struct {
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
const processIdleSubsystem = "process_idle"
|
||||
|
||||
func NewPGProcessIdleCollector(config collectorConfig) (Collector, error) {
|
||||
return &PGProcessIdleCollector{log: config.logger}, nil
|
||||
}
|
||||
|
@ -20,8 +20,10 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const replicationSubsystem = "replication"
|
||||
|
||||
func init() {
|
||||
registerCollector("replication", defaultEnabled, NewPGReplicationCollector)
|
||||
registerCollector(replicationSubsystem, defaultEnabled, NewPGReplicationCollector)
|
||||
}
|
||||
|
||||
type PGReplicationCollector struct {
|
||||
@ -33,12 +35,20 @@ func NewPGReplicationCollector(collectorConfig) (Collector, error) {
|
||||
|
||||
var (
|
||||
pgReplicationLag = prometheus.NewDesc(
|
||||
"pg_replication_lag",
|
||||
prometheus.BuildFQName(
|
||||
namespace,
|
||||
replicationSubsystem,
|
||||
"lag_seconds",
|
||||
),
|
||||
"Replication lag behind master in seconds",
|
||||
[]string{}, nil,
|
||||
)
|
||||
pgReplicationIsReplica = prometheus.NewDesc(
|
||||
"pg_replication_is_replica",
|
||||
prometheus.BuildFQName(
|
||||
namespace,
|
||||
replicationSubsystem,
|
||||
"is_replica",
|
||||
),
|
||||
"Indicates if the server is a replica",
|
||||
[]string{}, nil,
|
||||
)
|
||||
|
@ -21,8 +21,10 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const replicationSlotSubsystem = "replication_slot"
|
||||
|
||||
func init() {
|
||||
registerCollector("replication_slot", defaultEnabled, NewPGReplicationSlotCollector)
|
||||
registerCollector(replicationSlotSubsystem, defaultEnabled, NewPGReplicationSlotCollector)
|
||||
}
|
||||
|
||||
type PGReplicationSlotCollector struct {
|
||||
@ -35,17 +37,29 @@ func NewPGReplicationSlotCollector(config collectorConfig) (Collector, error) {
|
||||
|
||||
var (
|
||||
pgReplicationSlotCurrentWalDesc = prometheus.NewDesc(
|
||||
"pg_replication_slot_current_wal_lsn",
|
||||
prometheus.BuildFQName(
|
||||
namespace,
|
||||
replicationSlotSubsystem,
|
||||
"slot_current_wal_lsn",
|
||||
),
|
||||
"current wal lsn value",
|
||||
[]string{"slot_name"}, nil,
|
||||
)
|
||||
pgReplicationSlotCurrentFlushDesc = prometheus.NewDesc(
|
||||
"pg_replication_slot_confirmed_flush_lsn",
|
||||
prometheus.BuildFQName(
|
||||
namespace,
|
||||
replicationSlotSubsystem,
|
||||
"slot_confirmed_flush_lsn",
|
||||
),
|
||||
"last lsn confirmed flushed to the replication slot",
|
||||
[]string{"slot_name"}, nil,
|
||||
)
|
||||
pgReplicationSlotIsActiveDesc = prometheus.NewDesc(
|
||||
"pg_replication_slot_is_active",
|
||||
prometheus.BuildFQName(
|
||||
namespace,
|
||||
replicationSlotSubsystem,
|
||||
"slot_is_active",
|
||||
),
|
||||
"whether the replication slot is active or not",
|
||||
[]string{"slot_name"}, nil,
|
||||
)
|
@ -21,8 +21,10 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const bgWriterSubsystem = "stat_bgwriter"
|
||||
|
||||
func init() {
|
||||
registerCollector("bgwriter", defaultEnabled, NewPGStatBGWriterCollector)
|
||||
registerCollector(bgWriterSubsystem, defaultEnabled, NewPGStatBGWriterCollector)
|
||||
}
|
||||
|
||||
type PGStatBGWriterCollector struct {
|
||||
@ -32,8 +34,6 @@ func NewPGStatBGWriterCollector(collectorConfig) (Collector, error) {
|
||||
return &PGStatBGWriterCollector{}, nil
|
||||
}
|
||||
|
||||
const bgWriterSubsystem = "stat_bgwriter"
|
||||
|
||||
var (
|
||||
statBGWriterCheckpointsTimedDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, bgWriterSubsystem, "checkpoints_timed_total"),
|
||||
|
@ -20,8 +20,10 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const statDatabaseSubsystem = "stat_database"
|
||||
|
||||
func init() {
|
||||
registerCollector("stat_database", defaultEnabled, NewPGStatDatabaseCollector)
|
||||
registerCollector(statDatabaseSubsystem, defaultEnabled, NewPGStatDatabaseCollector)
|
||||
}
|
||||
|
||||
type PGStatDatabaseCollector struct{}
|
||||
@ -30,8 +32,6 @@ func NewPGStatDatabaseCollector(config collectorConfig) (Collector, error) {
|
||||
return &PGStatDatabaseCollector{}, nil
|
||||
}
|
||||
|
||||
const statDatabaseSubsystem = "stat_database"
|
||||
|
||||
var (
|
||||
statDatabaseNumbackends = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(
|
||||
|
@ -21,19 +21,19 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const statStatementsSubsystem = "stat_statements"
|
||||
|
||||
func init() {
|
||||
// WARNING:
|
||||
// Disabled by default because this set of metrics can be quite expensive on a busy server
|
||||
// Every unique query will cause a new timeseries to be created
|
||||
registerCollector("statements", defaultDisabled, NewPGStatStatementsCollector)
|
||||
registerCollector(statStatementsSubsystem, defaultDisabled, NewPGStatStatementsCollector)
|
||||
}
|
||||
|
||||
type PGStatStatementsCollector struct {
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
const statStatementsSubsystem = "stat_statements"
|
||||
|
||||
func NewPGStatStatementsCollector(config collectorConfig) (Collector, error) {
|
||||
return &PGStatStatementsCollector{log: config.logger}, nil
|
||||
}
|
||||
|
@ -22,16 +22,16 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const userTableSubsystem = "stat_user_tables"
|
||||
|
||||
func init() {
|
||||
registerCollector("user_tables", defaultEnabled, NewPGStatUserTablesCollector)
|
||||
registerCollector(userTableSubsystem, defaultEnabled, NewPGStatUserTablesCollector)
|
||||
}
|
||||
|
||||
type PGStatUserTablesCollector struct {
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
const userTableSubsystem = "stat_user_tables"
|
||||
|
||||
func NewPGStatUserTablesCollector(config collectorConfig) (Collector, error) {
|
||||
return &PGStatUserTablesCollector{log: config.logger}, nil
|
||||
}
|
||||
|
@ -21,16 +21,16 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const statioUserTableSubsystem = "statio_user_tables"
|
||||
|
||||
func init() {
|
||||
registerCollector("statio_user_tables", defaultEnabled, NewPGStatIOUserTablesCollector)
|
||||
registerCollector(statioUserTableSubsystem, defaultEnabled, NewPGStatIOUserTablesCollector)
|
||||
}
|
||||
|
||||
type PGStatIOUserTablesCollector struct {
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
const statioUserTableSubsystem = "statio_user_tables"
|
||||
|
||||
func NewPGStatIOUserTablesCollector(config collectorConfig) (Collector, error) {
|
||||
return &PGStatIOUserTablesCollector{log: config.logger}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user