Documentation ¶
Overview ¶
Package metricserver contains the web server powering metrics
Index ¶
Constants ¶
const PrometheusNamespace = "cnpg"
PrometheusNamespace is the namespace to be used for all custom metrics exposed by instances or the operator
Variables ¶
var DefaultQueries = m.UserQueries{ "collector": m.UserQuery{ Query: "SELECT current_database() as datname, relpages as lo_pages " + "FROM pg_class c JOIN pg_namespace n ON (n.oid = c.relnamespace) " + "WHERE n.nspname = 'pg_catalog' AND c.relname = 'pg_largeobject';", TargetDatabases: []string{"*"}, Metrics: []m.Mapping{ { "datname": m.ColumnMapping{ Usage: m.LABEL, Description: "Name of the database", }, }, { "lo_pages": m.ColumnMapping{ Usage: m.GAUGE, Description: "Estimated number of pages in the pg_largeobject table", }, }, }, }, }
DefaultQueries is the set of default queries for postgresql
Functions ¶
This section is empty.
Types ¶
type Exporter ¶
type Exporter struct { Metrics *metrics // contains filtered or unexported fields }
Exporter exports a set of metrics and collectors on a given postgres instance
func NewExporter ¶
NewExporter creates an exporter
func (*Exporter) Collect ¶
func (e *Exporter) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector, collecting the Metrics values to export.
func (*Exporter) Describe ¶
func (e *Exporter) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector, defining the Metrics we return.
func (*Exporter) SetCustomQueries ¶
func (e *Exporter) SetCustomQueries(queries *m.QueriesCollector)
SetCustomQueries sets the custom queries from the passed content
type MetricsServer ¶
MetricsServer exposes the metrics of the postgres instance
func New ¶
func New(serverInstance *postgres.Instance) (*MetricsServer, error)
New configure the web statusServer for a certain PostgreSQL instance, and must be invoked before starting the real web statusServer
func (*MetricsServer) GetExporter ¶
func (ms *MetricsServer) GetExporter() *Exporter
GetExporter get the exporter used for metrics. If the web statusServer still has not started, the exporter is nil
type PgCollector ¶
type PgCollector interface { // Name is the unique name of the collector Name() string // Collect collects data and send the metrics on the channel Collect(ch chan<- prometheus.Metric) error // Describe collects metadata about the metrics we work with Describe(ch chan<- *prometheus.Desc) }
PgCollector is the interface for all the collectors that need to do queries on PostgreSQL to gather the results
type PgStatWalMetrics ¶ added in v1.15.1
type PgStatWalMetrics struct { WalRecords *prometheus.GaugeVec WalFpi *prometheus.GaugeVec WalBytes *prometheus.GaugeVec WALBuffersFull *prometheus.GaugeVec WalWrite *prometheus.GaugeVec WalSync *prometheus.GaugeVec WalWriteTime *prometheus.GaugeVec WalSyncTime *prometheus.GaugeVec }
PgStatWalMetrics is available from PG14+