postgresql

package
v0.0.0-...-3667945 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: MIT Imports: 11 Imported by: 0

README

PostgreSQL plugin

This postgresql plugin provides metrics for your postgres database. It currently works with postgres versions 8.1+. It uses data from the built in pg_stat_database and pg_stat_bgwriter views. The metrics recorded depend on your version of postgres. See table:

pg version      9.2+   9.1   8.3-9.0   8.1-8.2   7.4-8.0(unsupported)
---             ---    ---   -------   -------   -------
datid            x      x       x         x
datname          x      x       x         x
numbackends      x      x       x         x         x
xact_commit      x      x       x         x         x
xact_rollback    x      x       x         x         x
blks_read        x      x       x         x         x
blks_hit         x      x       x         x         x
tup_returned     x      x       x
tup_fetched      x      x       x
tup_inserted     x      x       x
tup_updated      x      x       x
tup_deleted      x      x       x
conflicts        x      x
temp_files       x
temp_bytes       x
deadlocks        x
blk_read_time    x
blk_write_time   x
stats_reset*     x      x

* value ignored and therefore not recorded.

More information about the meaning of these metrics can be found in the PostgreSQL Documentation

Configuration

Specify address via a url matching:

postgres://[pqgotest[:password]]@localhost[/dbname]?sslmode=[disable|verify-ca|verify-full]

All connection parameters are optional. Without the dbname parameter, the driver will default to a database with the same name as the user. This dbname is just for instantiating a connection with the server and doesn't restrict the databases we are trying to grab metrics for.

A list of databases to explicitly ignore. If not specified, metrics for all databases are gathered. Do NOT use with the 'databases' option.

ignored_databases = ["postgres", "template0", "template1"]

A list of databases to pull metrics about. If not specified, metrics for all databases are gathered. Do NOT use with the 'ignored_databases' option.

databases = ["app_production", "testing"]

Configuration example
[[inputs.postgresql]]
  address = "postgres://telegraf@localhost/someDB"
  ignored_databases = ["template0", "template1"]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseURL

func ParseURL(uri string) (string, error)

pulled from lib/pq ParseURL no longer needs to be used by clients of this library since supplying a URL as a connection string to sql.Open() is now supported:

sql.Open("postgres", "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full")

It remains exported here for backwards-compatibility.

ParseURL converts a url to a connection string for driver.Open. Example:

"postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full"

converts to:

"user=bob password=secret host=1.2.3.4 port=5432 dbname=mydb sslmode=verify-full"

A minimal example:

"postgres://"

This will be blank, causing driver.Open to use all of the defaults

Types

type Postgresql

type Postgresql struct {
	Address          string
	Databases        []string
	IgnoredDatabases []string
	OrderedColumns   []string
	AllColumns       []string
	// contains filtered or unexported fields
}

func (*Postgresql) Description

func (p *Postgresql) Description() string

func (*Postgresql) Gather

func (p *Postgresql) Gather(acc telegraf.Accumulator) error

func (*Postgresql) IgnoredColumns

func (p *Postgresql) IgnoredColumns() map[string]bool

func (*Postgresql) SampleConfig

func (p *Postgresql) SampleConfig() string

func (*Postgresql) SanitizedAddress

func (p *Postgresql) SanitizedAddress() (_ string, err error)

Jump to

Keyboard shortcuts

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