collector

package
v1.0.0-beta4 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAndBind

func RunAndBind(config *Config)

Run executes a blocking http server. Starts the http listener with the /metrics endpoint and parses all configured metrics passed by config

Types

type AggregationResult

type AggregationResult map[string]interface{}

MongoDB aggregation result

type ChangeStreamEvent

type ChangeStreamEvent struct {
	NS *ChangeStreamEventNamespace
}

MongoDB event stream

type ChangeStreamEventNamespace

type ChangeStreamEventNamespace struct {
	DB   string
	Coll string
}

MongoDB event stream

type Collector

type Collector struct {
	Driver Driver
	Config *Config
}

The collector holds the configureation and the mongodb driver

func (*Collector) PullHandler

func (collector *Collector) PullHandler(metric *Metric)

Execute aggregations and update metrics in intervals

func (*Collector) PushHandler

func (collector *Collector) PushHandler(metric *Metric)

func (*Collector) Run

func (collector *Collector) Run()

Run metric collector for each metric either in push or pull mode

type Config

type Config struct {
	MongoDBConfig MongoDBConfig `mapstructure:"mongodb"`
	Bind          string
	LogLevel      string
	Metrics       []*Metric
}

Global configuration which holds all monitored aggregations

type Cursor

type Cursor interface {
	Next(ctx context.Context) bool
	Close(ctx context.Context) error
	Decode(val interface{}) error
}

Represents a cursor to fetch records from

type Driver

type Driver interface {
	Connect(ctx context.Context, opts ...*options.ClientOptions) error
	Ping(ctx context.Context, rp *readpref.ReadPref) error
	Aggregate(ctx context.Context, db string, col string, pipeline bson.A) (Cursor, error)
	Watch(ctx context.Context, db string, col string, pipeline mongo.Pipeline) (Cursor, error)
}

MongoDB driver abstraction

type Metric

type Metric struct {
	Name        string
	Type        string
	Help        string
	Value       string
	Interval    int64
	ConstLabels prometheus.Labels
	Mode        string
	Labels      []string
	Database    string
	Collection  string
	Pipeline    string
	// contains filtered or unexported fields
}

MongoDB aggregation metric

type MongoDBConfig

type MongoDBConfig struct {
	URI               string
	MaxConnections    int32
	ConnectionTimeout time.Duration
	DefaultInterval   int64
	DefaultDatabase   string
	DefaultCollection string
}

MongoDB client options

type MongoDBDriver

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

MongoDB driver

func (*MongoDBDriver) Aggregate

func (mdb *MongoDBDriver) Aggregate(ctx context.Context, db string, col string, pipeline bson.A) (Cursor, error)

Aggregation rquery

func (*MongoDBDriver) Connect

func (mdb *MongoDBDriver) Connect(ctx context.Context, opts ...*options.ClientOptions) error

Connect to the server

func (*MongoDBDriver) Ping

func (mdb *MongoDBDriver) Ping(ctx context.Context, rp *readpref.ReadPref) error

Enforce connection to the server

func (*MongoDBDriver) Watch

func (mdb *MongoDBDriver) Watch(ctx context.Context, db string, col string, pipeline mongo.Pipeline) (Cursor, error)

Start an eventstream

Jump to

Keyboard shortcuts

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