Documentation
¶
Index ¶
Constants ¶
const ( FilterPredNone = iota FilterPredContains FilterPredNotContains FilterPredStartsWith FilterPredEndsWith FilterPredEquals )
Filter predicates are used to filter out objects by name.
const ( FilterNone = iota FilterPred FilterParent )
Filter type is the type of filter applied to the objects.
const ( UnitNone = iota UnitBytes UnitKiB UnitMiB UnitGiB UnitTiB )
Units are the various units that may be associated with values in a rule.
const ( UnitSeconds = iota + 101 UnitMinutes UnitHours UnitDays )
Units for time.
const ( // server-level RuleServerWALCount = 1 // WAL: number of files is g/t <count> RuleServerWALReadyCount = 2 // WAL: number of files ready for archiving is g/t <count> RuleServerInactiveReplSlots = 3 // number of inactive repl slots is g/t <count> RuleServerPryWriteLag = 4 // primary: write lag is g/t <bytes> RuleServerPryFlushLag = 5 // primary: flush lag is g/t <bytes> RuleServerPryReplayLag = 6 // primary: replay lag is g/t <bytes> RuleServerSbyReplayLagBytes = 7 // standby: replay lag is g/t <bytes> RuleServerSbyReplayLagTime = 8 // standby: replay lag is g/t <time> RuleServerBELockWait = 9 // no. of backends waiting for locks is g/t <count> RuleServerBEIdleInTxn = 10 // no. of backends idling in txn is g/t <count> RuleServerBETxnOpen = 11 // no. of backends with txn open for more than <time> is g/t <count> RuleServerTxnIDRange = 12 // transaction id range is greater than <value> billion RuleServerLastCP = 13 // time since last checkpoint is g/t <time> // database-level RuleDBBECount = 101 // no. of backends is g/t <count> RuleDBBEPct = 102 // no. of backends is g/t <pct> % of max RuleDBCommitRatio = 103 // commit ratio is l/t <value> RuleDBTxnIDAge = 104 // txn id age is g/t <pct> % of autvacuum_freeze_max_age RuleDBSize = 105 // db size is g/t <bytes> RuleDBDisabledTriggers = 106 // disabled trigger count is g/t <count> RuleDBCacheHit = 107 // cache hit ratio is l/t <pct> % // table-level RuleTableAutoVacTime = 201 // time since last auto vacuum is g/t <time> RuleTableAutoAnaTime = 202 // time since last auto analyze is g/t <time> RuleTableManVacTime = 203 // time since last manual vacuum is g/t <time> RuleTableManAnaTime = 204 // time since last manual analyze is g/t <time> RuleTableBloatBytes = 205 // bloat is g/t <bytes> RuleTableBloatPct = 206 // bloat is g/t <pct> % of table size RuleTableSize = 207 // table size is g/t <bytes> RuleTableCacheHit = 208 // cache hit ratio is l/t <pct> % // tablespace-level RuleTSSize = 301 // table space size is g/t <bytes> RuleTSDiskFreePct = 302 // free disk pct is l/t <pct> % RuleTSInodesFreePct = 303 // free inodes pct is l/t <pct> % )
Rule IDs
const ( StatusNoData = -1 StatusOK = 0 StatusBreached = 1 )
The overall status of an alert.
Variables ¶
var ( // RxAPIKey is the regexp a valid API key should match. RxAPIKey = regexp.MustCompile("^[A-Za-z0-9]{22}$") // RxServer is the regexp a valid server name should match. RxServer = regexp.MustCompile("^[A-Za-z0-9_.-]{1,64}$") )
Functions ¶
This section is empty.
Types ¶
type AlertSettings ¶ added in v1.2.0
type AlertSettings struct {
Version int `json:"version"`
Rules []AlertingRule `json:"rules,omitempty"`
Emails []string `json:"emails,omitempty"`
}
AlertSettings represents the entire alert settings for a single server.
type AlertStatus ¶ added in v1.2.0
type AlertStatus struct {
Version int `json:"version"`
RuleStatus [][]AlertingRuleStatus `json:"status,omitempty"`
}
AlertStatus is the status of all rules, and corresponds to AlertSettings.
type AlertingRule ¶ added in v1.2.0
type AlertingRule struct {
RuleType int `json:"rule_type"`
Filter *Filter `json:"filter,omitempty"`
Value1 float64 `json:"value1"`
Unit1 int `json:"unit1,omitempty"`
Value2 float64 `json:"value2,omitempty"`
Unit2 int `json:"unit2,omitempty"`
Warn bool `json:"warn"`
}
AlertingRule represents a single alerting rule.
func (*AlertingRule) IsValid ¶ added in v1.2.0
func (a *AlertingRule) IsValid() bool
IsValid checks if this alerting rule is valid or not.
type AlertingRuleStatus ¶ added in v1.2.0
type AlertingRuleStatus struct {
Status int `json:"status"` // one of Status*
Database string `json:"db,omitempty"` // database name, if any
Table string `json:"table,omitempty"` // schema-qualified table name, if any
Tablespace string `json:"tblspc,omitempty"` // tablespace name, if any
Value float64 `json:"value"` // the actual value
Units string `json:"units,omitempty"` // the units for the value
}
AlertingRuleStatus is the status of one single AlertingRule.
type Filter ¶ added in v1.2.0
type Filter struct {
FilterType int `json:"filter_type"`
Predicate int `json:"pred"`
Value string `json:"value"`
}
Filter optionally restricts an alert rule to a subset of objects.
type ReqReport ¶ added in v1.1.0
type ReqReport struct {
APIKey string `json:"apikey"`
Server string `json:"server"`
Data pgmetrics.Model `json:"data"`
}
ReqReport is the request structure for RestV1.Report.
type RespReport ¶ added in v1.1.0
type RespReport struct {
}
RespReport is the response structure for RestV1.Report.
type RestV1 ¶
type RestV1 interface {
Quick(ctx context.Context, req ReqQuick) (resp RespQuick, code int)
Report(ctx context.Context, req ReqReport) (resp RespReport, code int)
}
RestV1 is the interface definition of the public REST API, v1.
type RestV1Client ¶
type RestV1Client struct {
// contains filtered or unexported fields
}
RestV1Client is a client for RestV1 servers.
func NewRestV1Client ¶
func NewRestV1Client(base string, timeout time.Duration, retries int) *RestV1Client
NewRestV1Client creates a new client to talk to the specified base URL and with the given timeout.
func (*RestV1Client) Quick ¶
func (c *RestV1Client) Quick(req ReqQuick) (resp RespQuick, err error)
Quick calls RestV1.Quick
func (*RestV1Client) Report ¶ added in v1.1.0
func (c *RestV1Client) Report(req ReqReport) (resp RespReport, err error)
Report calls RestV1.Report
func (*RestV1Client) SetDebug ¶ added in v1.3.5
func (c *RestV1Client) SetDebug(b bool)
SetDebug enables/disables debug output.
type RestV1ClientError ¶ added in v1.1.0
type RestV1ClientError struct {
// contains filtered or unexported fields
}
RestV1ClientError represents errors because of non-2xx HTTP response code.
func (*RestV1ClientError) Code ¶ added in v1.1.0
func (e *RestV1ClientError) Code() int
Code returns the HTTP response status code.
func (*RestV1ClientError) Error ¶ added in v1.1.0
func (e *RestV1ClientError) Error() string
Error returns a human-readable error message.