postgresql

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 18 Imported by: 0

README

postgresql

postgresql 监控采集插件

authorization

create user categraf with password 'categraf';
 
alter user categraf set default_transaction_read_only=on;

grant usage on schema public to categraf;

grant select on all tables in schema public to categraf ;

configuration

[[instances]]
address = ""
# labels = { region="", zone="" }
## postgresql 的连接信息
# address = "host=1.2.3.4 port=5432 user=postgres password=123456 sslmode=disable"

## outputaddress 相当于是addres的别名 
# outputaddress = "db01" 

## 一条连接保持活跃的最大时长, 0s表示永远
## 当查询执行时,到达最大时长的连接不会被立即强制断开
# max_lifetime = "0s"

## 忽略哪些db的采集
# ignored_databases = ["postgres", "template0", "template1"]

## 显式指定采集哪些db 
# databases = ["app_production", "testing"]

## Whether to use prepared statements when connecting to the database.
## This should be set to false when connecting through a PgBouncer instance
## with pool_mode set to transaction.
## 是否使用prepared statements 连接数据库
# prepared_statements = true

dashboard

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	config.InstanceConfig

	Address            string          `toml:"address"`
	MaxLifetime        config.Duration `toml:"max_lifetime"`
	IsPgBouncer        bool            `toml:"-"`
	OutputAddress      string          `toml:"outputaddress"`
	Databases          []string        `toml:"databases"`
	IgnoredDatabases   []string        `toml:"ignored_databases"`
	PreparedStatements bool            `toml:"prepared_statements"`
	Metrics            []MetricConfig  `toml:"metrics"`

	MaxIdle int
	MaxOpen int
	// contains filtered or unexported fields
}

func (*Instance) Drop

func (p *Instance) Drop()

closes any necessary channels and connections

func (*Instance) Gather

func (ins *Instance) Gather(slist *types.SampleList)

func (*Instance) IgnoredColumns

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

func (*Instance) Init

func (ins *Instance) Init() error

func (*Instance) SanitizedAddress

func (ins *Instance) SanitizedAddress() (sanitizedAddress string, err error)

SanitizedAddress utility function to strip sensitive information from the connection string.

type MetricConfig

type MetricConfig struct {
	Mesurement       string          `toml:"mesurement"`
	LabelFields      []string        `toml:"label_fields"`
	MetricFields     []string        `toml:"metric_fields"`
	FieldToAppend    string          `toml:"field_to_append"`
	Timeout          config.Duration `toml:"timeout"`
	Request          string          `toml:"request"`
	IgnoreZeroResult bool            `toml:"ignore_zero_result"`
}

type Postgresql

type Postgresql struct {
	config.PluginConfig
	Instances []*Instance `toml:"instances"`
}

func (*Postgresql) Clone

func (pt *Postgresql) Clone() inputs.Input

func (*Postgresql) Drop

func (pt *Postgresql) Drop()

func (*Postgresql) GetInstances

func (pt *Postgresql) GetInstances() []inputs.Instance

func (*Postgresql) Name

func (pt *Postgresql) Name() string

Jump to

Keyboard shortcuts

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