Documentation ¶
Index ¶
- Constants
- Variables
- func ReadStateFile(servers []*Server, globalCollectionOpts CollectionOpts, logger *util.Logger)
- func WriteStateFile(servers []*Server, globalCollectionOpts CollectionOpts, logger *util.Logger)
- type CPUInformation
- type CPUStatistic
- type CPUStatisticMap
- type CollectionOpts
- type CollectionStatus
- type CollectorConfig
- type CollectorPlatform
- type CollectorStats
- type DiffState
- type DiffedCollectorStats
- type DiffedDiskStats
- type DiffedDiskStatsMap
- type DiffedNetworkStats
- type DiffedNetworkStatsMap
- type DiffedPostgresFunctionStats
- type DiffedPostgresFunctionStatsMap
- type DiffedPostgresIndexStats
- type DiffedPostgresIndexStatsMap
- type DiffedPostgresRelationStats
- type DiffedPostgresRelationStatsMap
- type DiffedPostgresStatementStats
- type DiffedPostgresStatementStatsMap
- type DiffedSchemaStats
- type DiffedSystemCPUStats
- type DiffedSystemCPUStatsMap
- type Disk
- type DiskMap
- type DiskPartition
- type DiskPartitionMap
- type DiskStats
- type DiskStatsMap
- type Grant
- type GrantConfig
- type GrantFeatures
- type GrantLogs
- type GrantLogsEncryptionKey
- type GrantS3
- type HistoricStatementStatsMap
- type LogFile
- type LogLine
- type LogSecretKind
- type LogSecretMarker
- type Memory
- type NetworkStats
- type NetworkStatsMap
- type Oid
- type OidToIdxMap
- type PersistedActivityState
- type PersistedLogState
- type PersistedState
- type PostgresBackend
- type PostgresBackendCount
- type PostgresBloatStats
- type PostgresBuffercache
- type PostgresBuffercacheEntry
- type PostgresColumn
- type PostgresConstraint
- type PostgresDatabase
- type PostgresForeignSerialColumn
- type PostgresFunction
- type PostgresFunctionStats
- type PostgresFunctionStatsMap
- type PostgresIndex
- type PostgresIndexBloat
- type PostgresIndexStats
- type PostgresIndexStatsMap
- type PostgresQuerySample
- type PostgresRelation
- type PostgresRelationBloat
- type PostgresRelationStats
- type PostgresRelationStatsMap
- type PostgresReplication
- type PostgresReplicationStandby
- type PostgresRole
- type PostgresSequenceInformation
- type PostgresSequenceInformationMap
- type PostgresSequenceReport
- type PostgresSerialColumn
- type PostgresSetting
- type PostgresStatement
- type PostgresStatementKey
- type PostgresStatementMap
- type PostgresStatementStats
- type PostgresStatementStatsMap
- type PostgresStatementStatsTimeKey
- type PostgresStatementTextMap
- type PostgresVacuumProgress
- type PostgresVacuumStats
- type PostgresVacuumStatsEntry
- type PostgresVersion
- type Scheduler
- type SchemaStats
- type Server
- type StateOnDisk
- type SystemInfo
- type SystemInfoAmazonRds
- type SystemInfoSelfHosted
- type SystemState
- type SystemType
- type TransientActivityState
- type TransientLogState
- type TransientState
- type Xid
Constants ¶
const ( // CredentialLogSecret - Passwords and other credentials (e.g. private keys) CredentialLogSecret // ParsingErrorLogSecret - User supplied text during parsing errors - could contain anything, including credentials ParsingErrorLogSecret // StatementTextLogSecret - All statement texts (which may contain table data if not using bind parameters) StatementTextLogSecret // StatementParameterLogSecret - Bind parameters for a statement (which may contain table data for INSERT statements) StatementParameterLogSecret // TableDataLogSecret - Table data contained in constraint violations and COPY errors TableDataLogSecret // OpsLogSecret - System, network errors, file locations and configured commands (e.g. archive command) OpsLogSecret // UnidentifiedLogSecret - Text that could not be identified and might contain secrets UnidentifiedLogSecret )
const ( PostgresVersion93 = 90300 PostgresVersion94 = 90400 PostgresVersion95 = 90500 PostgresVersion96 = 90600 PostgresVersion10 = 100000 PostgresVersion11 = 110000 PostgresVersion12 = 120000 PostgresVersion13 = 130000 // MinRequiredPostgresVersion - We require PostgreSQL 9.3 or newer MinRequiredPostgresVersion = PostgresVersion93 )
Known PostgresVersion values - use these for checks in version-dependent code
const StateOnDiskFormatVersion = 4
StateOnDiskFormatVersion - Increment this when an old state preserved to disk should be ignored
Variables ¶
var AllLogSecretKinds = []LogSecretKind{ CredentialLogSecret, ParsingErrorLogSecret, StatementTextLogSecret, StatementParameterLogSecret, TableDataLogSecret, OpsLogSecret, UnidentifiedLogSecret, }
AllLogSecretKinds - List of all defined secret kinds
var ErrReplicaCollectionDisabled error = errors.New("monitored server is replica and replication collection disabled via config")
Functions ¶
func ReadStateFile ¶
func ReadStateFile(servers []*Server, globalCollectionOpts CollectionOpts, logger *util.Logger)
ReadStateFile - This reads in the prevState structs from the state file - only run this on initial bootup and SIGHUP!
func WriteStateFile ¶
func WriteStateFile(servers []*Server, globalCollectionOpts CollectionOpts, logger *util.Logger)
Types ¶
type CPUInformation ¶
type CPUStatistic ¶
type CPUStatistic struct { DiffedOnInput bool // True if has already been diffed on input (and we can simply copy the diff) DiffedValues *DiffedSystemCPUStats // Seconds (counter values that need to be diff-ed between runs) UserSeconds float64 SystemSeconds float64 IdleSeconds float64 NiceSeconds float64 IowaitSeconds float64 IrqSeconds float64 SoftIrqSeconds float64 StealSeconds float64 GuestSeconds float64 GuestNiceSeconds float64 }
CPUStatistic - Statistics for a single CPU core
func (CPUStatistic) DiffSince ¶
func (curr CPUStatistic) DiffSince(prev CPUStatistic) DiffedSystemCPUStats
DiffSince - Calculate the diff between two CPU stats runs
type CPUStatisticMap ¶
type CPUStatisticMap map[string]CPUStatistic
CPUStatisticMap - Map of all CPU statistics (Key = CPU ID)
type CollectionOpts ¶
type CollectionOpts struct { StartedAt time.Time CollectPostgresRelations bool CollectPostgresSettings bool CollectPostgresLocks bool CollectPostgresFunctions bool CollectPostgresBloat bool CollectPostgresViews bool CollectLogs bool CollectExplain bool CollectSystemInformation bool CollectorApplicationName string DiffStatements bool SubmitCollectedData bool TestRun bool TestReport string TestRunLogs bool TestExplain bool DebugLogs bool DiscoverLogLocation bool StateFilename string WriteStateUpdate bool ForceEmptyGrant bool }
type CollectionStatus ¶
type CollectorConfig ¶
type CollectorConfig struct { SectionName string DisableLogs bool DisableActivity bool EnableLogExplain bool DbName string DbUsername string DbHost string DbPort int32 DbSslmode string DbHasSslrootcert bool DbHasSslcert bool DbHasSslkey bool DbExtraNames []string DbAllNames bool DbURLRedacted string AwsRegion string AwsDbInstanceId string AwsHasAccessKeyId bool AwsHasAssumeRole bool AwsHasAccountId bool AzureDbServerName string AzureEventhubNamespace string AzureEventhubName string AzureAdTenantId string AzureAdClientId string AzureHasAdCertificate bool GcpCloudsqlInstanceId string GcpPubsubSubscription string GcpHasCredentialsFile bool GcpProjectId string ApiSystemId string ApiSystemType string ApiSystemScope string ApiSystemScopeFallback string DbLogLocation string DbLogDockerTail string IgnoreTablePattern string IgnoreSchemaRegexp string QueryStatsInterval int32 MaxCollectorConnections int32 SkipIfReplica bool FilterLogSecret string FilterQuerySample string FilterQueryText string HasProxy bool ConfigFromEnv bool }
type CollectorPlatform ¶
type CollectorStats ¶
type CollectorStats struct { GoVersion string MemoryHeapAllocatedBytes uint64 // Bytes allocated and not yet freed MemoryHeapObjects uint64 // Total number of allocated objects MemorySystemBytes uint64 // Bytes obtained from system (sum of heap and fixed-size structures) MemoryRssBytes uint64 // Memory allocated in bytes as seen by the OS ActiveGoroutines int32 CgoCalls int64 }
func (CollectorStats) DiffSince ¶
func (curr CollectorStats) DiffSince(prev CollectorStats) DiffedCollectorStats
type DiffState ¶
type DiffState struct { StatementStats DiffedPostgresStatementStatsMap SchemaStats map[Oid]*DiffedSchemaStats SystemCPUStats DiffedSystemCPUStatsMap SystemNetworkStats DiffedNetworkStatsMap SystemDiskStats DiffedDiskStatsMap CollectorStats DiffedCollectorStats }
DiffState - Result of diff-ing two persistent state structs
type DiffedCollectorStats ¶
type DiffedCollectorStats CollectorStats
type DiffedDiskStats ¶
type DiffedDiskStats struct { ReadOperationsPerSecond float64 // The average number of read requests that were issued to the device per second ReadsMergedPerSecond float64 // The average number of read requests merged per second that were queued to the device BytesReadPerSecond float64 // The average number of bytes read from the device per second AvgReadLatency float64 // The average time (in milliseconds) for read requests issued to the device to be served WriteOperationsPerSecond float64 // The average number of write requests that were issued to the device per second WritesMergedPerSecond float64 // The average number of write requests merged per second that were queued to the device BytesWrittenPerSecond float64 // The average number of bytes written to the device per second AvgWriteLatency float64 // The average time (in milliseconds) for write requests issued to the device to be served AvgQueueSize int32 // Average I/O operations in flight at the same time (waiting or worked on by the device) UtilizationPercent float64 // Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device) }
type DiffedDiskStatsMap ¶
type DiffedDiskStatsMap map[string]DiffedDiskStats
DiffedDiskStatsMap - Map of all diffed disk statistics (key = device name)
type DiffedNetworkStats ¶
type DiffedNetworkStats struct { ReceiveThroughputBytesPerSecond uint64 TransmitThroughputBytesPerSecond uint64 }
DiffedNetworkStats - Network statistics for a single interface as a diff
type DiffedNetworkStatsMap ¶
type DiffedNetworkStatsMap map[string]DiffedNetworkStats
DiffedNetworkStatsMap - Map of network statistics as a diff (Key = Interface Name)
type DiffedPostgresFunctionStats ¶
type DiffedPostgresFunctionStats PostgresFunctionStats
type DiffedPostgresFunctionStatsMap ¶
type DiffedPostgresFunctionStatsMap map[Oid]DiffedPostgresFunctionStats
type DiffedPostgresIndexStats ¶
type DiffedPostgresIndexStats PostgresIndexStats
type DiffedPostgresIndexStatsMap ¶
type DiffedPostgresIndexStatsMap map[Oid]DiffedPostgresIndexStats
type DiffedPostgresRelationStats ¶
type DiffedPostgresRelationStats PostgresRelationStats
type DiffedPostgresRelationStatsMap ¶
type DiffedPostgresRelationStatsMap map[Oid]DiffedPostgresRelationStats
type DiffedPostgresStatementStats ¶
type DiffedPostgresStatementStats PostgresStatementStats
func (DiffedPostgresStatementStats) Add ¶
func (stmt DiffedPostgresStatementStats) Add(other DiffedPostgresStatementStats) DiffedPostgresStatementStats
Add - Adds the statistics of one diffed statement to another, returning the result as a copy
type DiffedPostgresStatementStatsMap ¶
type DiffedPostgresStatementStatsMap map[PostgresStatementKey]DiffedPostgresStatementStats
type DiffedSchemaStats ¶
type DiffedSchemaStats struct { RelationStats DiffedPostgresRelationStatsMap IndexStats DiffedPostgresIndexStatsMap FunctionStats DiffedPostgresFunctionStatsMap }
type DiffedSystemCPUStats ¶
type DiffedSystemCPUStats struct { UserPercent float64 SystemPercent float64 IdlePercent float64 NicePercent float64 IowaitPercent float64 IrqPercent float64 SoftIrqPercent float64 StealPercent float64 GuestPercent float64 GuestNicePercent float64 }
DiffedSystemCPUStats - CPU statistics as percentages
type DiffedSystemCPUStatsMap ¶
type DiffedSystemCPUStatsMap map[string]DiffedSystemCPUStats
DiffedSystemCPUStatsMap - Map of all CPU statistics (Key = CPU ID)
type Disk ¶
type Disk struct { DiskType string // Disk type (hdd/sdd/io1/gp2) Scheduler string // Linux Scheduler (noop/anticipatory/deadline/cfq) ProvisionedIOPS uint32 // If applicable, how many IOPS are provisioned for this device Encrypted bool // If applicable, is this device encrypted? (default false) }
Disk - Information about an individual disk device in the system
type DiskPartition ¶
type DiskPartition struct { DiskName string // Name of the base device disk that this partition resides on (e.g. /dev/sda) PartitionName string // Platform-specific name of the partition (e.g. /dev/sda1) FilesystemType string FilesystemOpts string UsedBytes uint64 TotalBytes uint64 }
DiskPartition - Information and statistics about one of the disk partitions in the system
type DiskPartitionMap ¶
type DiskPartitionMap map[string]DiskPartition
DiskPartitionMap - Map of all disk partitions (key = mountpoint)
type DiskStats ¶
type DiskStats struct { DiffedOnInput bool // True if has already been diffed on input (and we can simply copy the diff) DiffedValues *DiffedDiskStats // Counter values ReadsCompleted uint64 // /proc/diskstats 4 - reads completed successfully ReadsMerged uint64 // /proc/diskstats 5 - reads merged BytesRead uint64 // /proc/diskstat 6 - sectors read, multiplied by sector size ReadTimeMs uint64 // /proc/diskstat 7 - time spent reading (ms) WritesCompleted uint64 // /proc/diskstats 8 - writes completed WritesMerged uint64 // /proc/diskstats 9 - writes merged BytesWritten uint64 // /proc/diskstat 10 - sectors written, multiplied by sector size WriteTimeMs uint64 // /proc/diskstat 11 - time spent writing (ms) AvgQueueSize int32 // /proc/diskstat 12 - I/Os currently in progress IoTime uint64 // /proc/diskstat 13 - time spent doing I/Os (ms) }
DiskStats - Statistics about an individual disk device in the system
type DiskStatsMap ¶
DiskStatsMap - Map of all disk statistics (key = device name)
type Grant ¶
type GrantConfig ¶
type GrantConfig struct { ServerID string `json:"server_id"` SentryDsn string `json:"sentry_dsn"` Features GrantFeatures `json:"features"` EnableActivity bool `json:"enable_activity"` EnableLogs bool `json:"enable_logs"` }
type GrantFeatures ¶
type GrantFeatures struct { Logs bool `json:"logs"` StatementResetFrequency int `json:"statement_reset_frequency"` StatementTimeoutMs int32 `json:"statement_timeout_ms"` // Statement timeout for all SQL statements sent to the database (defaults to 30s) StatementTimeoutMsQueryText int32 `json:"statement_timeout_ms_query_text"` // Statement timeout for pg_stat_statements query text requests (defaults to 120s) }
type GrantLogs ¶
type GrantLogs struct { Valid bool Logdata GrantS3 `json:"logdata"` Snapshot GrantS3 `json:"snapshot"` EncryptionKey GrantLogsEncryptionKey `json:"encryption_key"` }
type GrantLogsEncryptionKey ¶
type HistoricStatementStatsMap ¶
type HistoricStatementStatsMap map[PostgresStatementStatsTimeKey]DiffedPostgresStatementStatsMap
type LogFile ¶
type LogFile struct { LogLines []LogLine UUID uuid.UUID S3Location string S3CekAlgo string S3CmkKeyID string ByteSize int64 OriginalName string TmpFile *os.File FilterLogSecret []LogSecretKind }
LogFile - Log file that we are uploading for reference in log line metadata
type LogLine ¶
type LogLine struct { UUID uuid.UUID ParentUUID uuid.UUID ByteStart int64 ByteContentStart int64 ByteEnd int64 // Written log line ends *before* this index OccurredAt time.Time Username string Database string Query string Application string SchemaName string RelationName string // Only used for collector-internal bookkeeping to determine how long to wait // for associating related loglines with each other CollectedAt time.Time LogLevel pganalyze_collector.LogLineInformation_LogLevel BackendPid int32 // %l in log_line_prefix (or similar in syslog) LogLineNumber int32 // Syslog chunk number (within a particular line) LogLineNumberChunk int32 Content string Classification pganalyze_collector.LogLineInformation_LogClassification Details map[string]interface{} RelatedPids []int32 ReviewedForSecrets bool SecretMarkers []LogSecretMarker }
LogLine - "Line" in a Postgres log file, and the associated analysis metadata
type LogSecretKind ¶
type LogSecretKind int
LogSecretKind - Enum to classify the kind of log secret identified by a marker
func ParseFilterLogSecret ¶
func ParseFilterLogSecret(input string) (result []LogSecretKind)
type LogSecretMarker ¶
type LogSecretMarker struct { // ! Note that these byte indices are from the *content* start of a log line ByteStart int // Start of the secret in the log line content ByteEnd int // End of the secret in the log line content (secret ends *before* this index) Kind LogSecretKind }
LogSecretMarker - Marks log secrets in a log line
type Memory ¶
type Memory struct { TotalBytes uint64 CachedBytes uint64 BuffersBytes uint64 FreeBytes uint64 WritebackBytes uint64 DirtyBytes uint64 SlabBytes uint64 MappedBytes uint64 PageTablesBytes uint64 ActiveBytes uint64 InactiveBytes uint64 AvailableBytes uint64 SwapUsedBytes uint64 SwapTotalBytes uint64 HugePagesSizeBytes uint64 HugePagesFree uint64 HugePagesTotal uint64 HugePagesReserved uint64 HugePagesSurplus uint64 ApplicationBytes uint64 }
Memory - Metrics related to system memory
type NetworkStats ¶
type NetworkStats struct { DiffedOnInput bool // True if has already been diffed on input (and we can simply copy the diff) DiffedValues *DiffedNetworkStats ReceiveThroughputBytes uint64 TransmitThroughputBytes uint64 }
NetworkStats - Information about the network activity on a single interface
func (NetworkStats) DiffSince ¶
func (curr NetworkStats) DiffSince(prev NetworkStats, collectedIntervalSecs uint32) DiffedNetworkStats
DiffSince - Calculate the diff between two network stats runs
type NetworkStatsMap ¶
type NetworkStatsMap map[string]NetworkStats
NetworkStatsMap - Map of all network statistics (Key = Interface Name)
type OidToIdxMap ¶
func MakeOidToIdxMap ¶
func MakeOidToIdxMap() OidToIdxMap
func (OidToIdxMap) Get ¶
func (m OidToIdxMap) Get(dbOid, objOid Oid) int32
func (OidToIdxMap) Put ¶
func (m OidToIdxMap) Put(dbOid, objOid Oid, idx int32)
type PersistedActivityState ¶
type PersistedLogState ¶
type PersistedState ¶
type PersistedState struct { CollectedAt time.Time StatementStats PostgresStatementStatsMap SchemaStats map[Oid]*SchemaStats Relations []PostgresRelation Functions []PostgresFunction System SystemState CollectorStats CollectorStats // Incremented every run, indicates whether we should run a pg_stat_statements_reset() // on behalf of the user. Only activates once it reaches GrantFeatures.StatementReset, // and is reset afterwards. StatementResetCounter int // Keep track of when we last collected statement stats, to calculate time distance LastStatementStatsAt time.Time // All statement stats that have not been identified (will be cleared by the next full snapshot) UnidentifiedStatementStats HistoricStatementStatsMap }
PersistedState - State thats kept across collector runs to be used for diffs
type PostgresBackend ¶
type PostgresBackend struct { Identity uint64 // Combination of process start time and PID, used to identify a process over time DatabaseOid null.Int // OID of the database this backend is connected to DatabaseName null.String // Name of the database this backend is connected to RoleOid null.Int // OID of the user logged into this backend RoleName null.String // Name of the user logged into this backend Pid int32 // Process ID of this backend ApplicationName null.String // Name of the application that is connected to this backend ClientAddr null.String // IP address of the client connected to this backend. If this field is null, it indicates either that the client is connected via a Unix socket on the server machine or that this is an internal process such as autovacuum. ClientPort null.Int // TCP port number that the client is using for communication with this backend, or -1 if a Unix socket is used BackendStart null.Time // Time when this process was started, i.e., when the client connected to the server XactStart null.Time // Time when this process' current transaction was started, or null if no transaction is active. If the current query is the first of its transaction, this column is equal to the query_start column. QueryStart null.Time // Time when the currently active query was started, or if state is not active, when the last query was started StateChange null.Time // Time when the state was last changed Waiting null.Bool // True if this backend is currently waiting on a lock BackendXid null.Int // Top-level transaction identifier of this backend, if any. BackendXmin null.Int // The current backend's xmin horizon. WaitEventType null.String // 9.6+ The type of event for which the backend is waiting, if any; otherwise NULL WaitEvent null.String // 9.6+ Wait event name if backend is currently waiting, otherwise NULL BackendType null.String // 10+ The process type of this backend Query null.String // Text of this backend's most recent query // Current overall state of this backend. Possible values are: // - active: The backend is executing a query. // - idle: The backend is waiting for a new client command. // - idle in transaction: The backend is in a transaction, but is not currently executing a query. // - idle in transaction (aborted): This state is similar to idle in transaction, except one of the statements in the transaction caused an error. // - fastpath function call: The backend is executing a fast-path function. // - disabled: This state is reported if track_activities is disabled in this backend. State null.String }
PostgresBackend - PostgreSQL server backend thats currently working, waiting or idling (also known as an open connection)
See https://www.postgresql.org/docs/9.5/static/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
type PostgresBackendCount ¶
type PostgresBackendCount struct { DatabaseOid null.Int // OID of the database RoleOid null.Int // OID of the user State string // Current overall state of this backend BackendType string // The process type of this backend WaitingForLock bool // True if this backend is currently waiting on a heavyweight lock Count int32 // Number of this kind of backends }
type PostgresBloatStats ¶
type PostgresBloatStats struct { DatabaseName string Relations []PostgresRelationBloat Indices []PostgresIndexBloat }
type PostgresBuffercache ¶
type PostgresBuffercache struct { TotalBytes int64 FreeBytes int64 Entries []PostgresBuffercacheEntry }
PostgresBuffercache - Details on whats contained in the Postgres buffer cache
type PostgresBuffercacheEntry ¶
type PostgresBuffercacheEntry struct { Bytes int64 DatabaseName string SchemaName *string ObjectName *string ObjectKind *string Toast bool }
PostgresBuffercacheEntry - One entry in the buffercache statistics (already aggregated)
type PostgresColumn ¶
type PostgresConstraint ¶
type PostgresConstraint struct { RelationOid Oid // The table this constraint is on Name string // Constraint name (not necessarily unique!) Type string // c = check constraint, f = foreign key constraint, p = primary key constraint, u = unique constraint, t = constraint trigger, x = exclusion constraint ConstraintDef string // Human-readable representation of the expression Columns []int32 // If a table constraint (including foreign keys, but not constraint triggers), list of the constrained columns ForeignOid Oid // If a foreign key, the referenced table ForeignColumns []int32 // If a foreign key, list of the referenced columns ForeignUpdateType string // Foreign key update action code: a = no action, r = restrict, c = cascade, n = set null, d = set default ForeignDeleteType string // Foreign key deletion action code: a = no action, r = restrict, c = cascade, n = set null, d = set default ForeignMatchType string // Foreign key match type: f = full, p = partial, s = simple }
type PostgresDatabase ¶
type PostgresDatabase struct { Oid Oid // ID of this database Name string // Database name OwnerRoleOid Oid // Owner of the database, usually the user who created it Encoding string // Character encoding for this database Collate string // LC_COLLATE for this database CType string // LC_CTYPE for this database IsTemplate bool // If true, then this database can be cloned by any user with CREATEDB privileges; if false, then only superusers or the owner of the database can clone it. AllowConnections bool // If false then no one can connect to this database. This is used to protect the template0 database from being altered. ConnectionLimit int32 // Sets maximum number of concurrent connections that can be made to this database. -1 means no limit. // All transaction IDs before this one have been replaced with a permanent ("frozen") transaction ID in this database. // This is used to track whether the database needs to be vacuumed in order to prevent transaction ID wraparound or to // allow pg_clog to be shrunk. It is the minimum of the per-table pg_class.relfrozenxid values. FrozenXID Xid // All multixact IDs before this one have been replaced with a transaction ID in this database. // This is used to track whether the database needs to be vacuumed in order to prevent multixact ID wraparound or to // allow pg_multixact to be shrunk. It is the minimum of the per-table pg_class.relminmxid values. MinimumMultixactXID Xid }
PostgresDatabase - A database in the PostgreSQL system, with multiple schemas and tables contained in it
type PostgresFunction ¶
type PostgresFunction struct { Oid Oid DatabaseOid Oid SchemaName string `json:"schema_name"` FunctionName string `json:"function_name"` Language string `json:"language"` Source string `json:"source"` SourceBin null.String `json:"source_bin"` Config []string `json:"config"` Arguments string `json:"arguments"` Result string `json:"result"` Kind string `json:"kind"` SecurityDefiner bool `json:"security_definer"` Leakproof bool `json:"leakproof"` Strict bool `json:"strict"` ReturnsSet bool `json:"returns_set"` Volatile string `json:"volatile"` }
PostgresFunction - Function/Stored Procedure that runs on the PostgreSQL server
type PostgresFunctionStats ¶
type PostgresFunctionStats struct { Calls int64 `json:"calls"` TotalTime float64 `json:"total_time"` SelfTime float64 `json:"self_time"` }
PostgresFunctionStats - Statistics about a single PostgreSQL function
Note that this will only be populated when "track_functions" is enabled.
func (PostgresFunctionStats) DiffSince ¶
func (curr PostgresFunctionStats) DiffSince(prev PostgresFunctionStats) DiffedPostgresFunctionStats
type PostgresFunctionStatsMap ¶
type PostgresFunctionStatsMap map[Oid]PostgresFunctionStats
type PostgresIndex ¶
type PostgresIndex struct { RelationOid Oid IndexOid Oid IndexType string // Equivalent with pg_am.amname, e.g. "btree", "gist", "gin", "brin" Columns []int32 Name string IsPrimary bool IsUnique bool IsValid bool IndexDef string ConstraintDef null.String Options map[string]string }
func (PostgresIndex) Fillfactor ¶
func (i PostgresIndex) Fillfactor() int32
Fillfactor - Returns the FILLFACTOR storage parameter set on the index, the default if known (90 for btree), or -1 if unknown
type PostgresIndexBloat ¶
type PostgresIndexStats ¶
type PostgresIndexStats struct { SizeBytes int64 IdxScan int64 // Number of index scans initiated on this index IdxTupRead int64 // Number of index entries returned by scans on this index IdxTupFetch int64 // Number of live table rows fetched by simple index scans using this index IdxBlksRead int64 // Number of disk blocks read from this index IdxBlksHit int64 // Number of buffer hits in this index }
func (PostgresIndexStats) DiffSince ¶
func (curr PostgresIndexStats) DiffSince(prev PostgresIndexStats) DiffedPostgresIndexStats
type PostgresIndexStatsMap ¶
type PostgresIndexStatsMap map[Oid]PostgresIndexStats
type PostgresQuerySample ¶
type PostgresQuerySample struct { OccurredAt time.Time Username string Database string Query string Parameters []null.String LogLineUUID uuid.UUID RuntimeMs float64 HasExplain bool ExplainOutput string ExplainError string ExplainFormat pganalyze_collector.QuerySample_ExplainFormat ExplainSource pganalyze_collector.QuerySample_ExplainSource }
type PostgresRelation ¶
type PostgresRelation struct { Oid Oid DatabaseOid Oid SchemaName string RelationName string RelationType string PersistenceType string Columns []PostgresColumn Indices []PostgresIndex Constraints []PostgresConstraint ViewDefinition string Options map[string]string HasOids bool HasInheritanceChildren bool HasToast bool FrozenXID Xid MinimumMultixactXID Xid ParentTableOid Oid PartitionBoundary string PartitionStrategy string PartitionColumns []int32 PartitionedBy string // True if another process is currently holding an AccessExclusiveLock on this // relation, this also means we don't collect columns/index/constraints data ExclusivelyLocked bool }
func (PostgresRelation) Fillfactor ¶
func (r PostgresRelation) Fillfactor() int32
Fillfactor - Returns the FILLFACTOR storage parameter set on the table, or the default (100)
type PostgresRelationBloat ¶
type PostgresRelationStats ¶
type PostgresRelationStats struct { SizeBytes int64 // On-disk size including FSM and VM, plus TOAST table if any, excluding indices ToastSizeBytes int64 // TOAST table and TOAST index size (included in SizeBytes as well) SeqScan int64 // Number of sequential scans initiated on this table SeqTupRead int64 // Number of live rows fetched by sequential scans IdxScan int64 // Number of index scans initiated on this table IdxTupFetch int64 // Number of live rows fetched by index scans NTupIns int64 // Number of rows inserted NTupUpd int64 // Number of rows updated NTupDel int64 // Number of rows deleted NTupHotUpd int64 // Number of rows HOT updated (i.e., with no separate index update required) NLiveTup int64 // Estimated number of live rows NDeadTup int64 // Estimated number of dead rows NModSinceAnalyze null.Int // Estimated number of rows modified since this table was last analyzed LastVacuum null.Time // Last time at which this table was manually vacuumed (not counting VACUUM FULL) LastAutovacuum null.Time // Last time at which this table was vacuumed by the autovacuum daemon LastAnalyze null.Time // Last time at which this table was manually analyzed LastAutoanalyze null.Time // Last time at which this table was analyzed by the autovacuum daemon VacuumCount int64 // Number of times this table has been manually vacuumed (not counting VACUUM FULL) AutovacuumCount int64 // Number of times this table has been vacuumed by the autovacuum daemon AnalyzeCount int64 // Number of times this table has been manually analyzed AutoanalyzeCount int64 // Number of times this table has been analyzed by the autovacuum daemon HeapBlksRead int64 // Number of disk blocks read from this table HeapBlksHit int64 // Number of buffer hits in this table IdxBlksRead int64 // Number of disk blocks read from all indexes on this table IdxBlksHit int64 // Number of buffer hits in all indexes on this table ToastBlksRead int64 // Number of disk blocks read from this table's TOAST table (if any) ToastBlksHit int64 // Number of buffer hits in this table's TOAST table (if any) TidxBlksRead int64 // Number of disk blocks read from this table's TOAST table indexes (if any) TidxBlksHit int64 // Number of buffer hits in this table's TOAST table indexes (if any) }
func (PostgresRelationStats) DiffSince ¶
func (curr PostgresRelationStats) DiffSince(prev PostgresRelationStats) DiffedPostgresRelationStats
type PostgresRelationStatsMap ¶
type PostgresRelationStatsMap map[Oid]PostgresRelationStats
type PostgresReplication ¶
type PostgresReplication struct { InRecovery bool // Data available on primary CurrentXlogLocation null.String Standbys []PostgresReplicationStandby // Data available on standby IsStreaming null.Bool ReceiveLocation null.String ReplayLocation null.String ApplyByteLag null.Int ReplayTimestamp null.Time ReplayTimestampAge null.Int }
type PostgresReplicationStandby ¶
type PostgresReplicationStandby struct { ClientAddr string RoleOid Oid Pid int64 ApplicationName string ClientHostname null.String ClientPort int32 BackendStart time.Time SyncPriority int32 SyncState string State string SentLocation null.String WriteLocation null.String FlushLocation null.String ReplayLocation null.String RemoteByteLag null.Int LocalByteLag null.Int }
PostgresReplicationStandby - Standby information as seen from the primary
type PostgresRole ¶
type PostgresRole struct { Oid Oid // ID of role Name string // Role name Inherit bool // Role automatically inherits privileges of roles it is a member of Login bool // Role can log in. That is, this role can be given as the initial session authorization identifier CreateDb bool // Role can create databases CreateRole bool // Role can create more roles SuperUser bool // Role has superuser privileges Replication bool // Role can initiate streaming replication and put the system in and out of backup mode. BypassRLS bool // Role bypasses every row level security policy, see https://www.postgresql.org/docs/9.5/static/ddl-rowsecurity.html ConnectionLimit int32 // For roles that can log in, this sets maximum number of concurrent connections this role can make. -1 means no limit. PasswordValidUntil null.Time // Password expiry time (only used for password authentication); null if no expiration Config []string // Role-specific defaults for run-time configuration variables MemberOf []Oid // List of roles that this role is a member of (i.e. whose permissions it inherits) }
PostgresRole - A role in the PostgreSQL system - note that this includes users (Login=true)
type PostgresSequenceInformationMap ¶
type PostgresSequenceInformationMap map[Oid]PostgresSequenceInformation
type PostgresSequenceReport ¶
type PostgresSequenceReport struct { DatabaseName string Sequences PostgresSequenceInformationMap SerialColumns []PostgresSerialColumn ForeignSerialColumns []PostgresForeignSerialColumn }
type PostgresSerialColumn ¶
type PostgresSetting ¶
type PostgresSetting struct { Name string `json:"name"` CurrentValue null.String `json:"current_value"` Unit null.String `json:"unit"` BootValue null.String `json:"boot_value"` ResetValue null.String `json:"reset_value"` Source null.String `json:"source"` SourceFile null.String `json:"sourcefile"` SourceLine null.String `json:"sourceline"` }
type PostgresStatement ¶
type PostgresStatement struct { Fingerprint [21]byte // Fingerprint for a specific statement InsufficientPrivilege bool // True if we're missing permissions to see the statement Collector bool // True if this statement was produced by the pganalyze collector }
PostgresStatement - Specific kind of statement that has run one or multiple times on the PostgreSQL server.
type PostgresStatementKey ¶
type PostgresStatementKey struct { DatabaseOid Oid // OID of database in which the statement was executed UserOid Oid // OID of user who executed the statement QueryID int64 // Postgres 9.4+: Internal hash code, computed from the statement's parse tree }
PostgresStatementKey - Information that uniquely identifies a query
type PostgresStatementMap ¶
type PostgresStatementMap map[PostgresStatementKey]PostgresStatement
type PostgresStatementStats ¶
type PostgresStatementStats struct { Calls int64 // Number of times executed TotalTime float64 // Total time spent in the statement, in milliseconds Rows int64 // Total number of rows retrieved or affected by the statement LocalBlksHit int64 // Total number of local block cache hits by the statement LocalBlksRead int64 // Total number of local blocks read by the statement LocalBlksDirtied int64 // Total number of local blocks dirtied by the statement LocalBlksWritten int64 // Total number of local blocks written by the statement TempBlksRead int64 // Total number of temp blocks read by the statement TempBlksWritten int64 // Total number of temp blocks written by the statement BlkReadTime float64 // Total time the statement spent reading blocks, in milliseconds (if track_io_timing is enabled, otherwise zero) BlkWriteTime float64 // Total time the statement spent writing blocks, in milliseconds (if track_io_timing is enabled, otherwise zero) // Postgres 9.5+ MinTime null.Float // Minimum time spent in the statement, in milliseconds MaxTime null.Float // Maximum time spent in the statement, in milliseconds MeanTime null.Float // Mean time spent in the statement, in milliseconds StddevTime null.Float // Population standard deviation of time spent in the statement, in milliseconds }
PostgresStatementStats - Statistics from pg_stat_statements extension for a given statement.
See also https://www.postgresql.org/docs/9.5/static/pgstatstatements.html
func (PostgresStatementStats) DiffSince ¶
func (curr PostgresStatementStats) DiffSince(prev PostgresStatementStats) DiffedPostgresStatementStats
type PostgresStatementStatsMap ¶
type PostgresStatementStatsMap map[PostgresStatementKey]PostgresStatementStats
type PostgresVacuumProgress ¶
type PostgresVacuumProgress struct { VacuumIdentity uint64 // Combination of vacuum "query" start time and PID, used to identify a vacuum over time BackendIdentity uint64 // Combination of process start time and PID, used to identify a process over time DatabaseName string SchemaName string RelationName string RoleName string StartedAt time.Time Autovacuum bool Toast bool Phase string HeapBlksTotal int64 HeapBlksScanned int64 HeapBlksVacuumed int64 IndexVacuumCount int64 MaxDeadTuples int64 NumDeadTuples int64 }
PostgresVacuumProgress - PostgreSQL vacuum thats currently running
See https://www.postgresql.org/docs/10/static/progress-reporting.html
type PostgresVacuumStats ¶
type PostgresVacuumStats struct { DatabaseName string // Database-wide settings AutovacuumMaxWorkers int32 AutovacuumNaptimeSeconds int32 // Defaults for per-table settings AutovacuumEnabled bool AutovacuumVacuumThreshold int32 AutovacuumAnalyzeThreshold int32 AutovacuumVacuumScaleFactor float64 AutovacuumAnalyzeScaleFactor float64 AutovacuumFreezeMaxAge int32 AutovacuumMultixactFreezeMaxAge int32 AutovacuumVacuumCostDelay int32 AutovacuumVacuumCostLimit int32 Relations []PostgresVacuumStatsEntry }
PostgresVacuumStats - Details on VACUUM configuration and expected runs
type PostgresVacuumStatsEntry ¶
type PostgresVacuumStatsEntry struct { SchemaName string RelationName string LiveRowCount int32 DeadRowCount int32 Relfrozenxid int32 Relminmxid int32 LastManualVacuumRun null.Time LastAutoVacuumRun null.Time LastManualAnalyzeRun null.Time LastAutoAnalyzeRun null.Time AutovacuumEnabled bool AutovacuumVacuumThreshold int32 AutovacuumAnalyzeThreshold int32 AutovacuumVacuumScaleFactor float64 AutovacuumAnalyzeScaleFactor float64 AutovacuumFreezeMaxAge int32 AutovacuumMultixactFreezeMaxAge int32 AutovacuumVacuumCostDelay int32 AutovacuumVacuumCostLimit int32 Fillfactor int32 }
PostgresVacuumStatsEntry - One entry in the VACUUM statistics
type PostgresVersion ¶
type PostgresVersion struct { Full string `json:"full"` // e.g. "PostgreSQL 9.5.1 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit" Short string `json:"short"` // e.g. "9.5.1" Numeric int `json:"numeric"` // e.g. 90501 // For collector use only, to avoid calling functions that don't work IsAwsAurora bool IsCitus bool }
PostgresVersion - Identifying information about the PostgreSQL server version and build details
type SchemaStats ¶
type SchemaStats struct { RelationStats PostgresRelationStatsMap IndexStats PostgresIndexStatsMap FunctionStats PostgresFunctionStatsMap }
type Server ¶
type Server struct { Config config.ServerConfig RequestedSslMode string Grant Grant PGAnalyzeURL string PrevState PersistedState StateMutex *sync.Mutex LogPrevState PersistedLogState LogStateMutex *sync.Mutex ActivityPrevState PersistedActivityState ActivityStateMutex *sync.Mutex CollectionStatus CollectionStatus CollectionStatusMutex *sync.Mutex }
type StateOnDisk ¶
type StateOnDisk struct { FormatVersion uint PrevStateByServer map[config.ServerIdentifier]PersistedState }
type SystemInfo ¶
type SystemInfo struct { Type SystemType SystemScope string SystemID string SelfHosted *SystemInfoSelfHosted AmazonRds *SystemInfoAmazonRds BootTime time.Time }
type SystemInfoAmazonRds ¶
type SystemInfoAmazonRds struct { Region string InstanceClass string InstanceID string Status string AvailabilityZone string PubliclyAccessible bool MultiAz bool SecondaryAvailabilityZone string CaCertificate string AutoMinorVersionUpgrade bool PreferredMaintenanceWindow string PreferredBackupWindow string LatestRestorableTime time.Time BackupRetentionPeriodDays int32 MasterUsername string InitialDbName string CreatedAt time.Time StorageProvisionedIOPS int32 StorageAllocatedGigabytes int32 StorageEncrypted bool StorageType string EnhancedMonitoring bool PerformanceInsights bool PostgresLogExport bool IAMAuthentication bool DeletionProtection bool ParameterApplyStatus string ParameterPgssEnabled bool ParameterAutoExplainEnabled bool IsAuroraPostgres bool }
SystemInfoAmazonRds - System information for Amazon RDS systems
type SystemInfoSelfHosted ¶
type SystemInfoSelfHosted struct { Hostname string Architecture string OperatingSystem string Platform string PlatformFamily string PlatformVersion string VirtualizationSystem string // Name of the virtualization system (only if we're a guest) KernelVersion string DatabaseSystemIdentifier string }
SystemInfoSelfHosted - System information for self-hosted systems (both physical and virtual)
type SystemState ¶
type SystemState struct { Info SystemInfo Scheduler Scheduler Memory Memory CPUInfo CPUInformation CPUStats CPUStatisticMap NetworkStats NetworkStatsMap Disks DiskMap DiskStats DiskStatsMap DiskPartitions DiskPartitionMap DataDirectoryPartition string // Partition that the data directory lives on (identified by the partition's mountpoint) XlogPartition string // Partition that the WAL directory lives on XlogUsedBytes uint64 }
SystemState - All kinds of system-related information and metrics
type SystemType ¶
type SystemType int
SystemType - Enum that describes which kind of system we're monitoring
const ( SelfHostedSystem SystemType = iota AmazonRdsSystem HerokuSystem GoogleCloudSQLSystem AzureDatabaseSystem )
Treat this list as append-only and never change the order
type TransientActivityState ¶
type TransientActivityState struct { CollectedAt time.Time TrackActivityQuerySize int Version PostgresVersion Backends []PostgresBackend Vacuums []PostgresVacuumProgress }
type TransientLogState ¶
type TransientLogState struct { CollectedAt time.Time LogFiles []LogFile QuerySamples []PostgresQuerySample }
func (TransientLogState) Cleanup ¶
func (ls TransientLogState) Cleanup()
type TransientState ¶
type TransientState struct { // Databases we connected to and fetched local catalog data (e.g. schema) DatabaseOidsWithLocalCatalog []Oid Roles []PostgresRole Databases []PostgresDatabase Statements PostgresStatementMap StatementTexts PostgresStatementTextMap HistoricStatementStats HistoricStatementStatsMap // This is a new zero value that was recorded after a pg_stat_statements_reset(), // in order to enable the next snapshot to be able to diff against something ResetStatementStats PostgresStatementStatsMap Replication PostgresReplication Settings []PostgresSetting BackendCounts []PostgresBackendCount Version PostgresVersion SentryClient *raven.Client CollectorConfig CollectorConfig CollectorPlatform CollectorPlatform }
TransientState - State thats only used within a collector run (and not needed for diffs)
Source Files ¶
- activity.go
- collector_stats.go
- errors.go
- logs.go
- postgres_backend.go
- postgres_buffercache.go
- postgres_database.go
- postgres_function.go
- postgres_query_sample.go
- postgres_relation_bloat.go
- postgres_relation_stats.go
- postgres_relations.go
- postgres_replication.go
- postgres_role.go
- postgres_sequence_report.go
- postgres_setting.go
- postgres_statement.go
- postgres_types.go
- postgres_vacuum.go
- postgres_vacuum_progress.go
- postgres_version.go
- state.go
- state_file.go
- system.go
- util.go