exporter

package
v0.42.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 33 Imported by: 1

Documentation

Overview

Package exporter implements the collectors and metrics handlers.

Index

Constants

View Source
const (
	// PrimaryState is the state of the primary node in a replica set.
	// See: https://docs.mongodb.com/manual/reference/replica-states/
	PrimaryState = 1

	// SecondaryState is the state of a secondary node in a replica set.
	SecondaryState = 2

	// UnknownState is the state of an unknown node in a replica set.
	UnknownState = 6

	// ArbiterState is the state of an arbiter in a replica set.
	ArbiterState = 7

	// EnterpriseEdition shows that MongoDB is Enterprise edition.
	EnterpriseEdition = "Enterprise"
	// CommunityEdition shows that MongoDB is Community edition.
	CommunityEdition = "Community"

	// PerconaVendor means that MongoDB provided by Percona.
	PerconaVendor = "Percona"
	// MongoDBVendor means that MongoDB provided by Mongo.
	MongoDBVendor = "MongoDB"
)

Variables

View Source
var ErrCannotGetTopologyLabels = fmt.Errorf("cannot get topology labels")

ErrCannotGetTopologyLabels Cannot read topology labels.

View Source
var ErrInvalidOrMissingInprogEntry = errors.New("invalid or missing inprog entry in currentop results")
View Source
var ErrInvalidOrMissingTotalsEntry = fmt.Errorf("invalid or misssing totals entry in top results")

Functions

func GetSeedListFromSRV added in v0.42.0

func GetSeedListFromSRV(uri string, log *logrus.Logger) string

GetSeedListFromSRV converts mongodb+srv URI to flat connection string.

func OverallTargetsHandler added in v0.42.0

func OverallTargetsHandler(exporters []*Exporter, logger *logrus.Logger) http.HandlerFunc

OverallTargetsHandler is a handler to scrape all the targets in one request. Adds instance label to each metric.

func RunWebServer added in v0.40.0

func RunWebServer(opts *ServerOpts, exporters []*Exporter, log *logrus.Logger)

Runs the main web-server

Types

type Exporter

type Exporter struct {
	// contains filtered or unexported fields
}

Exporter holds Exporter methods and attributes.

func New

func New(opts *Opts) *Exporter

New connects to the database and returns a new Exporter instance.

func (*Exporter) Handler added in v0.30.0

func (e *Exporter) Handler() http.Handler

Handler returns an http.Handler that serves metrics. Can be used instead of run for hooking up custom HTTP servers.

type GathererWrapped added in v0.42.0

type GathererWrapped struct {
	// contains filtered or unexported fields
}

GathererWrapped is a wrapper for prometheus.Gatherer that adds labels to all metrics.

func NewGathererWrapper added in v0.42.0

func NewGathererWrapper(gs prometheus.Gatherer, labels prometheus.Labels) *GathererWrapped

NewGathererWrapper creates a new GathererWrapped with the given Gatherer and additional labels.

func (*GathererWrapped) Gather added in v0.42.0

Gather implements prometheus.Gatherer interface.

type Opts

type Opts struct {
	// Only get stats for the collections matching this list of namespaces.
	// Example: db1.col1,db.col1
	CollStatsNamespaces    []string
	CollStatsLimit         int
	CompatibleMode         bool
	DirectConnect          bool
	ConnectTimeoutMS       int
	DisableDefaultRegistry bool
	DiscoveringMode        bool
	GlobalConnPool         bool
	ProfileTimeTS          int
	TimeoutOffset          int
	CurrentOpSlowTime      string

	CollectAll               bool
	EnableDBStats            bool
	EnableDBStatsFreeStorage bool
	EnableDiagnosticData     bool
	EnableReplicasetStatus   bool
	EnableReplicasetConfig   bool
	EnableCurrentopMetrics   bool
	EnableTopMetrics         bool
	EnableIndexStats         bool
	EnableCollStats          bool
	EnableProfile            bool
	EnableShards             bool
	EnableFCV                bool // Feature Compatibility Version.

	EnableOverrideDescendingIndex bool

	// Enable metrics for Percona Backup for MongoDB (PBM).
	EnablePBMMetrics bool

	IndexStatsCollections []string
	Logger                *logrus.Logger

	URI      string
	NodeName string
}

Opts holds new exporter options.

func GetRequestOpts added in v0.42.0

func GetRequestOpts(filters []string, defaultOpts *Opts) Opts

GetRequestOpts makes exporter.Opts structure from request filters and default options.

type ServerMap added in v0.40.0

type ServerMap map[string]http.Handler

ServerMap stores http handlers for each host

type ServerOpts added in v0.40.0

type ServerOpts struct {
	Path                   string
	MultiTargetPath        string
	OverallTargetPath      string
	WebListenAddress       string
	TLSConfigPath          string
	DisableDefaultRegistry bool
}

ServerOpts is the options for the main http handler

type ShardingChangelogStats

type ShardingChangelogStats struct {
	Items *[]ShardingChangelogSummary
}

ShardingChangelogStats is an array of Sharding changelog stats.

type ShardingChangelogSummary

type ShardingChangelogSummary struct {
	ID    *ShardingChangelogSummaryID `bson:"_id"`
	Count float64                     `bson:"count"`
}

ShardingChangelogSummary Sharding Changelog Summary.

type ShardingChangelogSummaryID

type ShardingChangelogSummaryID struct {
	Event string `bson:"event"`
	Note  string `bson:"note"`
}

ShardingChangelogSummaryID Sharding Changelog Summary ID.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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