exporter

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package exporter defines a metrics exporter interface that is used by an agent to export metrics into the desired metrics provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(ctx *appcontext.Context, provider Provider) (ExportFunc, GetterFunc, error)

Initialize method initializes the exporter and returns a function that exports the metrics.

func Register

func Register(name string, fn newFunc)

Register adds a new exporter to the package. This does not throw an error, rather panics if the exporter with the same name is already registered, hence an exporter should be registered inside the init method of the package.

Types

type ExportFunc

type ExportFunc = func(context.Context, []checker.Metric) error

ExportFunc is the function that is used to export the metrics into the provider.

type Exporter

type Exporter interface {
	// Provision provisions the exporter. Creates database connection and
	// sets other configuration for the exporter.
	Provision(*appcontext.Context, Provider) error

	// Export is the function that does the actual exporting.
	Export(context.Context, []checker.Metric) error

	// GetMetrics get the metrics for the given check IDs. It accepts a `duration`
	// parameter that fetches metrics for the check in the past `duration`.
	//
	// In the resultant map, each of the metrics array should be ordered in
	// descending order of their start times. This process usually happens in
	// the database much quicker than processing it on here so it is required
	// that the exporter returns metrics in the correct order.
	GetMetrics(_ context.Context, _ time.Duration, checkIDs ...string) (map[string][]checker.Metric, error)
}

Exporter is anything that can export metrics into the database provider.

type GetterFunc

type GetterFunc = func(context.Context, time.Duration, ...string) (map[string][]checker.Metric, error)

GetterFunc is the function that fetches metrics from the database for the given checks.

type Provider

type Provider interface {
	GetBackend() string // Returns the provider backend name.

	GetHost() string     // Returns the host.
	GetPort() uint16     // Returns the port.
	GetDBName() string   // Returns the database name.
	GetUsername() string // Returns the username.
	GetPassword() string // Returns the password.
	IsSSLMode() bool     // Tells if connection is through SSL mode.
}

Provider is anything that can be used to configure and create a metrics exporter.

Directories

Path Synopsis
Package influxdb implements the influxdb exporter.
Package influxdb implements the influxdb exporter.
Package log implements the log metrics exporter.
Package log implements the log metrics exporter.
Package timescale implements the timescale metrics exporter.
Package timescale implements the timescale metrics exporter.

Jump to

Keyboard shortcuts

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