Documentation
¶
Index ¶
- func DBToFloat64(t interface{}) (float64, bool)
- func DBToString(t interface{}) (string, bool)
- func GetDataSources() []string
- func MakeDescMap(pgVersion semver.Version, serverLabels prometheus.Labels, ...) map[string]MetricMapNamespace
- func ParseConstLabels(s string) prometheus.Labels
- func ParseFingerprint(url string) (string, error)
- func ParseVersion(versionString string) (semver.Version, error)
- func PrintExporterMaps(exp *Exporter)
- func QuerySettings(ch chan<- prometheus.Metric, server *Server) error
- type ColumnMapping
- type ColumnUsage
- type ErrorConnectToServer
- type Exporter
- type ExporterOpt
- type MetricMap
- type MetricMapNamespace
- type OverrideQuery
- type Server
- type ServerOpt
- type Servers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DBToFloat64 ¶
DBToFloat64 Convert database.sql types to float64s for Prometheus consumption. Null types are mapped to NaN. string and []byte types are mapped as NaN and !ok
func DBToString ¶
DBToString Convert database.sql to string for Prometheus labels. Null types are mapped to empty strings.
func GetDataSources ¶
func GetDataSources() []string
func MakeDescMap ¶
func MakeDescMap(pgVersion semver.Version, serverLabels prometheus.Labels, metricMaps map[string]map[string]ColumnMapping) map[string]MetricMapNamespace
MakeDescMap Abstracting the private function for now This turns the MetricMap column mapping into a prometheus descriptor mapping.
func ParseConstLabels ¶
func ParseConstLabels(s string) prometheus.Labels
func ParseFingerprint ¶
func PrintExporterMaps ¶
func PrintExporterMaps(exp *Exporter)
func QuerySettings ¶
func QuerySettings(ch chan<- prometheus.Metric, server *Server) error
Types ¶
type ColumnMapping ¶
type ColumnMapping struct {
// contains filtered or unexported fields
}
ColumnMapping is the user-friendly representation of a prometheus descriptor map
func NewColumnMapping ¶
func NewColumnMapping(u ColumnUsage, desc string, mapping *map[string]float64, ver semver.Range) *ColumnMapping
func (*ColumnMapping) GetSupportedVersions ¶
func (cm *ColumnMapping) GetSupportedVersions() semver.Range
func (*ColumnMapping) SetSupportedVersions ¶
func (cm *ColumnMapping) SetSupportedVersions(ver semver.Range)
func (*ColumnMapping) UnmarshalYAML ¶
func (cm *ColumnMapping) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements yaml.Unmarshaller
type ColumnUsage ¶
type ColumnUsage int
ColumnUsage should be one of several enum values which describe how a queried row is to be converted to a Prometheus metric.
const ( DISCARD ColumnUsage = iota // Ignore this column LABEL ColumnUsage = iota // Use this column as a label COUNTER ColumnUsage = iota // Use this column as a counter GAUGE ColumnUsage = iota // Use this column as a gauge MAPPEDMETRIC ColumnUsage = iota // Use this column with the supplied mapping of text values DURATION ColumnUsage = iota // This column should be interpreted as a text duration (and converted to milliseconds) )
nolint: golint
func (*ColumnUsage) UnmarshalYAML ¶
func (cu *ColumnUsage) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the yaml.Unmarshaller interface.
type ErrorConnectToServer ¶
type ErrorConnectToServer struct {
Msg string
}
ErrorConnectToServer is a connection to PgSQL server error
func (*ErrorConnectToServer) Error ¶
func (e *ErrorConnectToServer) Error() string
Error returns error
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter collects Postgres metrics. It implements prometheus.Collector.
func NewExporter ¶
func NewExporter(dsn []string, opts ...ExporterOpt) *Exporter
NewExporter returns a new PostgreSQL exporter for the provided DSN.
func (*Exporter) CloseAllServers ¶
func (e *Exporter) CloseAllServers()
func (*Exporter) Collect ¶
func (e *Exporter) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector.
func (*Exporter) Describe ¶
func (e *Exporter) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector.
type ExporterOpt ¶
type ExporterOpt func(*Exporter)
ExporterOpt configures Exporter.
func AutoDiscoverDatabases ¶
func AutoDiscoverDatabases(b bool) ExporterOpt
AutoDiscoverDatabases allows scraping all databases on a database server.
func DisableDefaultMetrics ¶
func DisableDefaultMetrics(b bool) ExporterOpt
DisableDefaultMetrics configures default metrics export.
func DisableSettingsMetrics ¶
func DisableSettingsMetrics(b bool) ExporterOpt
DisableSettingsMetrics configures pg_settings export.
func ExcludeDatabases ¶
func ExcludeDatabases(s string) ExporterOpt
ExcludeDatabases allows to filter out result from AutoDiscoverDatabases
func WithConstantLabels ¶
func WithConstantLabels(s string) ExporterOpt
WithConstantLabels configures constant labels.
func WithUserQueriesPath ¶
func WithUserQueriesPath(p string) ExporterOpt
WithUserQueriesPath configures user's queries path.
type MetricMap ¶
type MetricMap struct {
// contains filtered or unexported fields
}
MetricMap stores the prometheus metric description which a given column will be mapped to by the collector
func (*MetricMap) GetDiscard ¶
type MetricMapNamespace ¶
type MetricMapNamespace struct {
// contains filtered or unexported fields
}
MetricMapNamespace groups metric maps under a shared set of labels.
func GetNamespace ¶
func GetNamespace(metricMapNamespaces *map[string]MetricMapNamespace, mapName string) *MetricMapNamespace
func (*MetricMapNamespace) GetColumnMapping ¶
func (mmn *MetricMapNamespace) GetColumnMapping(mapName string) *MetricMap
func (*MetricMapNamespace) GetMetricMap ¶
func (mmn *MetricMapNamespace) GetMetricMap(metricMapNamespaces *map[string]MetricMapNamespace, namespace string, mapName string) *MetricMap
type OverrideQuery ¶
type OverrideQuery struct {
// contains filtered or unexported fields
}
OverrideQuery 's are run in-place of simple namespace look ups, and provide advanced functionality. But they have a tendency to postgres version specific. There aren't too many versions, so we simply store customized versions using the semver matching we do for columns.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server describes a connection to Postgres. Also it contains metrics map and query overrides.
func (*Server) Ping ¶
Ping checks connection availability and possibly invalidates the connection if it fails.
type ServerOpt ¶
type ServerOpt func(*Server)
ServerOpt configures a server.
func ServerWithLabels ¶
func ServerWithLabels(labels prometheus.Labels) ServerOpt
ServerWithLabels configures a set of labels.
type Servers ¶
type Servers struct {
// contains filtered or unexported fields
}
Servers contains a collection of servers to Postgres.
func NewServers ¶
NewServers creates a collection of servers to Postgres.