pgmonitor

package
v2.7.1-0...-d77f34b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExporterPort = int32(9187)

	// TODO: With the current implementation of the crunchy-postgres-exporter
	// it makes sense to hard-code the database. When moving away from the
	// crunchy-postgres-exporter start.sh script we should re-evaluate always
	// setting the exporter database to `postgres`.
	ExporterDB = "postgres"

	// The exporter connects to all databases over loopback using a password.
	// Kubernetes guarantees localhost resolves to loopback:
	// https://kubernetes.io/docs/concepts/cluster-administration/networking/
	// https://releases.k8s.io/v1.21.0/pkg/kubelet/kubelet_pods.go#L343
	ExporterHost = "localhost"
)
View Source
const (
	// MonitoringUser is a Postgres user created by pgMonitor configuration
	MonitoringUser = "ccp_monitoring"
)

Variables

View Source
var (
	ExporterWebConfigFileFlag          = "--web.config.file=/web-config/web-config.yml"
	ExporterDeactivateStatBGWriterFlag = "--no-collector.stat_bgwriter"
)

postgres_exporter command flags

View Source
var DefaultValuesForQueries = map[string]string{
	"PGBACKREST_INFO_THROTTLE_MINUTES":    "10",
	"PG_STAT_STATEMENTS_LIMIT":            "20",
	"PG_STAT_STATEMENTS_THROTTLE_MINUTES": "-1",
}

Defaults for certain values used in queries.yml TODO(dsessler7): make these values configurable via spec

Functions

func DisableExporterInPostgreSQL

func DisableExporterInPostgreSQL(ctx context.Context, exec postgres.Executor) error

DisableExporterInPostgreSQL disables the exporter configuration in PostgreSQL. Currently the exporter is disabled by removing login permissions for the monitoring user. TODO: evaluate other uninstall/removal options

func EnableExporterInPostgreSQL

func EnableExporterInPostgreSQL(ctx context.Context, exec postgres.Executor,
	monitoringSecret *corev1.Secret, database, setup string) error

EnableExporterInPostgreSQL runs SQL setup commands in `database` to enable the exporter to retrieve metrics. pgMonitor objects are created and expected extensions are installed. We also ensure that the monitoring user has the current password and can login.

func ExporterEnabled

func ExporterEnabled(cluster *v1beta1.PostgresCluster) bool

ExporterEnabled returns true if the monitoring exporter is enabled

func ExporterStartCommand

func ExporterStartCommand(builtinCollectors bool, commandFlags ...string) []string

ExporterStartCommand generates an entrypoint that will create a master queries file and start the postgres_exporter. It will repeat those steps if it notices a change in the source queries files.

func GenerateDefaultExporterQueries

func GenerateDefaultExporterQueries(ctx context.Context, cluster *v1beta1.PostgresCluster) string

GenerateDefaultExporterQueries generates the default queries used by exporter

func GetQueriesConfigDir

func GetQueriesConfigDir(ctx context.Context) string

func PostgreSQLHBAs

func PostgreSQLHBAs(inCluster *v1beta1.PostgresCluster, outHBAs *postgres.HBAs)

PostgreSQLHBAs provides the Postgres HBA rules for allowing the monitoring exporter to be accessible

func PostgreSQLParameters

func PostgreSQLParameters(inCluster *v1beta1.PostgresCluster, outParameters *postgres.Parameters)

PostgreSQLParameters provides additional required configuration parameters that Postgres needs to support monitoring

Types

type Executor

type Executor func(
	ctx context.Context, stdin io.Reader, stdout, stderr io.Writer, command ...string,
) error

func (Executor) GetExporterSetupSQL

func (exec Executor) GetExporterSetupSQL(ctx context.Context, version int) (string, string, error)

GetExporterSQL takes the PostgreSQL version and returns the corresponding setup.sql file that is defined in the exporter container

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL