metricserver

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: Apache-2.0 Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package metricserver contains the web server powering metrics

Index

Constants

View Source
const PrometheusNamespace = "cnpg"

PrometheusNamespace is the namespace to be used for all custom metrics exposed by instances or the operator

Variables

View Source
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

func NewExporter(instance *postgres.Instance) *Exporter

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

type MetricsServer struct {
	*webserver.Webserver
	// contains filtered or unexported fields
}

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+

Jump to

Keyboard shortcuts

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