monitor - ActiveState ActiveGo 1.8
...

Package monitor

import "github.com/influxdata/influxdb/monitor"
Overview
Index
Subdirectories

Overview ▾

Package monitor provides a service and associated functionality for InfluxDB to self-monitor internal statistics and diagnostics.

Constants

const (
    // DefaultStoreEnabled is whether the system writes gathered information in
    // an InfluxDB system for historical analysis.
    DefaultStoreEnabled = true

    // DefaultStoreDatabase is the name of the database where gathered information is written.
    DefaultStoreDatabase = "_internal"

    // DefaultStoreInterval is the period between storing gathered information.
    DefaultStoreInterval = 10 * time.Second
)

Policy constants.

const (
    // Name of the retention policy used by the monitor service.
    MonitorRetentionPolicy = "monitor"

    // Duration of the monitor retention policy.
    MonitorRetentionPolicyDuration = 7 * 24 * time.Hour

    // Default replication factor to set on the monitor retention policy.
    MonitorRetentionPolicyReplicaN = 1
)

func DiagnosticsFromMap

func DiagnosticsFromMap(m map[string]interface{}) *diagnostics.Diagnostics

DiagnosticsFromMap returns a Diagnostics from a map.

type Config

Config represents the configuration for the monitor service.

type Config struct {
    StoreEnabled  bool          `toml:"store-enabled"`
    StoreDatabase string        `toml:"store-database"`
    StoreInterval toml.Duration `toml:"store-interval"`
}

func NewConfig

func NewConfig() Config

NewConfig returns an instance of Config with defaults.

func (Config) Validate

func (c Config) Validate() error

Validate validates that the configuration is acceptable.

type Monitor

Monitor represents an instance of the monitor system.

type Monitor struct {
    // Build information for diagnostics.
    Version   string
    Commit    string
    Branch    string
    BuildTime string

    MetaClient interface {
        CreateDatabaseWithRetentionPolicy(name string, spec *meta.RetentionPolicySpec) (*meta.DatabaseInfo, error)
        Database(name string) *meta.DatabaseInfo
    }

    // Writer for pushing stats back into the database.
    PointsWriter PointsWriter

    Logger zap.Logger
    // contains filtered or unexported fields
}

func New

func New(r Reporter, c Config) *Monitor

New returns a new instance of the monitor system.

func (*Monitor) Close

func (m *Monitor) Close() error

Close closes the monitor system.

func (*Monitor) DeregisterDiagnosticsClient

func (m *Monitor) DeregisterDiagnosticsClient(name string)

DeregisterDiagnosticsClient deregisters a diagnostics client by name.

func (*Monitor) Diagnostics

func (m *Monitor) Diagnostics() (map[string]*diagnostics.Diagnostics, error)

Diagnostics fetches diagnostic information for each registered diagnostic client. It skips any clients that return an error when retrieving their diagnostics.

func (*Monitor) Open

func (m *Monitor) Open() error

Open opens the monitoring system, using the given clusterID, node ID, and hostname for identification purpose.

func (*Monitor) RegisterDiagnosticsClient

func (m *Monitor) RegisterDiagnosticsClient(name string, client diagnostics.Client)

RegisterDiagnosticsClient registers a diagnostics client with the given name and tags.

func (*Monitor) SetGlobalTag

func (m *Monitor) SetGlobalTag(key string, value interface{})

SetGlobalTag can be used to set tags that will appear on all points written by the Monitor.

func (*Monitor) SetPointsWriter

func (m *Monitor) SetPointsWriter(pw PointsWriter) error

SetPointsWriter can be used to set a writer for the monitoring points.

func (*Monitor) Statistics

func (m *Monitor) Statistics(tags map[string]string) ([]*Statistic, error)

Statistics returns the combined statistics for all expvar data. The given tags are added to each of the returned statistics.

func (*Monitor) WithLogger

func (m *Monitor) WithLogger(log zap.Logger)

WithLogger sets the logger for the Monitor.

type PointsWriter

PointsWriter is a simplified interface for writing the points the monitor gathers.

type PointsWriter interface {
    WritePoints(database, retentionPolicy string, points models.Points) error
}

type RemoteWriterConfig

RemoteWriterConfig represents the configuration of a remote writer.

type RemoteWriterConfig struct {
    RemoteAddr string
    NodeID     string
    Username   string
    Password   string
    ClusterID  uint64
}

type Reporter

Reporter is an interface for gathering internal statistics.

type Reporter interface {
    // Statistics returns the statistics for the reporter,
    // with the given tags merged into the result.
    Statistics(tags map[string]string) []models.Statistic
}

type Statistic

Statistic represents the information returned by a single monitor client.

type Statistic struct {
    models.Statistic
}

func (*Statistic) ValueNames

func (s *Statistic) ValueNames() []string

ValueNames returns a sorted list of the value names, if any.

type Statistics

Statistics is a slice of sortable statistics.

type Statistics []*Statistic

func (Statistics) Len

func (a Statistics) Len() int

Len implements sort.Interface.

func (Statistics) Less

func (a Statistics) Less(i, j int) bool

Less implements sort.Interface.

func (Statistics) Swap

func (a Statistics) Swap(i, j int)

Swap implements sort.Interface.

Subdirectories

Name Synopsis
..
diagnostics Package diagnostics provides the diagnostics type so that other packages can provide diagnostics without depending on the monitor package.