Documentation
¶
Index ¶
- Constants
- func ActiveConnections(pgPool *pgxpool.Pool) func(ctx context.Context, state *agent.MetricsState) error
- func AlterDatabase(pgPool *pgxpool.Pool, dbname string, name string, value string) error
- func AlterSystem(pgPool *pgxpool.Pool, name string, value string) error
- func Autovacuum(pgPool *pgxpool.Pool) func(ctx context.Context, state *agent.MetricsState) error
- func BufferCacheHitRatio(pgPool *pgxpool.Pool) func(ctx context.Context, state *agent.MetricsState) error
- func DataDirectory(pgPool *pgxpool.Pool) (string, error)
- func DatabaseSize(pgPool *pgxpool.Pool) func(ctx context.Context, state *agent.MetricsState) error
- func DetectConfigFromConfigFile() bool
- func DetectConfigFromEnv() bool
- func GetActiveConfig(pool *pgxpool.Pool, ctx context.Context, logger *logrus.Logger) (agent.ConfigArraySchema, error)
- func MaxConnections(pgPool *pgxpool.Pool) (uint32, error)
- func PGStatStatements(pgPool *pgxpool.Pool) func(ctx context.Context, state *agent.MetricsState) error
- func PGVersion(pgPool *pgxpool.Pool) (string, error)
- func ReloadConfig(pgPool *pgxpool.Pool) error
- func Select1(pgPool *pgxpool.Pool) error
- func TransactionsPerSecond(pgPool *pgxpool.Pool) func(ctx context.Context, state *agent.MetricsState) error
- func UptimeMinutes(pgPool *pgxpool.Pool) func(ctx context.Context, state *agent.MetricsState) error
- func WaitEvents(pgPool *pgxpool.Pool) func(ctx context.Context, state *agent.MetricsState) error
- func WaitPostgresReady(pgPool *pgxpool.Pool) error
- type Config
Constants ¶
View Source
const ActiveConnectionsQuery = `
/*dbtune*/
SELECT COUNT(*) AS active_connections
FROM pg_stat_activity
WHERE state = 'active'
`
View Source
const AlterDatabaseQuery = `
/*dbtune*/
ALTER DATABASE %s SET %s = %s;
`
View Source
const AlterSystemQuery = `
/*dbtune*/
ALTER SYSTEM SET %s = %s;
`
View Source
const AutovacuumQuery = `
/*dbtune*/
SELECT COUNT(*) FROM pg_stat_activity WHERE query LIKE 'autovacuum:%';
`
https://stackoverflow.com/a/25012622
View Source
const BufferCacheHitRatioQuery = `
/*dbtune*/
SELECT blks_hit, blks_read
FROM pg_stat_database
WHERE datname = current_database();
`
View Source
const (
DEFAULT_CONFIG_KEY = "postgresql"
)
View Source
const DataDirectoryQuery = `
/*dbtune*/
SHOW data_directory;
`
View Source
const DatabaseSizeQuery = `
/*dbtune*/
SELECT sum(pg_database_size(datname)) as total_size_bytes FROM pg_database;
`
View Source
const MaxConnectionsQuery = `
/*dbtune*/
SELECT setting::integer FROM pg_settings WHERE name = 'max_connections';
`
View Source
const PGVersionQuery = `
/*dbtune*/
SELECT version();
`
PGVersion returns the version of the PostgreSQL instance
View Source
const PgStatStatementsQuery = `` /* 322-byte string literal not displayed */
View Source
const ReloadConfigQuery = `
/*dbtune*/
SELECT pg_reload_conf();
`
View Source
const SELECT_NON_NUMERIC_SETTINGS = `
/*dbtune*/
SELECT name, setting, unit, vartype, context
FROM pg_settings
WHERE vartype NOT IN ('real', 'integer');
`
View Source
const SELECT_NUMERIC_SETTINGS = `` /* 138-byte string literal not displayed */
View Source
const Select1Query = `
/*dbtune*/
SELECT 1;
`
View Source
const TransactionsPerSecondQuery = `
/*dbtune*/
SELECT SUM(xact_commit)::bigint
AS server_xact_commits
FROM pg_stat_database;
`
View Source
const UptimeMinutesQuery = `
/*dbtune*/
SELECT EXTRACT(EPOCH FROM (current_timestamp - pg_postmaster_start_time())) / 60 as uptime_minutes;
`
View Source
const WaitEventsQuery = `` /* 690-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func ActiveConnections ¶
func AlterDatabase ¶
func Autovacuum ¶
func BufferCacheHitRatio ¶
func BufferCacheHitRatio(pgPool *pgxpool.Pool) func(ctx context.Context, state *agent.MetricsState) error
BufferCacheHitRatio returns the buffer cache hit ratio based on delta calculations. This implementation calculates the hit ratio based on the difference between two consecutive snapshots, providing a more meaningful metric for recent performance.
func DatabaseSize ¶
DatabaseSize returns the size of all the databases combined in bytes
func DetectConfigFromConfigFile ¶
func DetectConfigFromConfigFile() bool
func DetectConfigFromEnv ¶
func DetectConfigFromEnv() bool
func GetActiveConfig ¶
func PGStatStatements ¶
func ReloadConfig ¶
func TransactionsPerSecond ¶
func UptimeMinutes ¶ added in v0.3.3
func WaitEvents ¶
func WaitPostgresReady ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.