package monitor
import "github.com/influxdata/influxdb/monitor"
Package monitor provides a service and associated functionality for InfluxDB to self-monitor internal statistics and diagnostics.
Index ¶
- Constants
- type Config
- func NewConfig() Config
- func (c Config) Diagnostics() (*diagnostics.Diagnostics, error)
- func (c Config) Validate() error
- type Monitor
- func New(r Reporter, c Config) *Monitor
- func (m *Monitor) Close() error
- func (m *Monitor) DeregisterDiagnosticsClient(name string)
- func (m *Monitor) Diagnostics() (map[string]*diagnostics.Diagnostics, error)
- func (m *Monitor) Enabled() bool
- func (m *Monitor) Open() error
- func (m *Monitor) RegisterDiagnosticsClient(name string, client diagnostics.Client)
- func (m *Monitor) SetGlobalTag(key string, value interface{})
- func (m *Monitor) SetPointsWriter(pw PointsWriter) error
- func (m *Monitor) Statistics(tags map[string]string) ([]*Statistic, error)
- func (m *Monitor) WithLogger(log *zap.Logger)
- func (m *Monitor) WritePoints(p models.Points) error
- type PointsWriter
- type RemoteWriterConfig
- type Reporter
- type Statistic
- type Statistics
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 )
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 )
Policy constants.
Types ¶
type Config ¶
type Config struct { StoreEnabled bool `toml:"store-enabled"` StoreDatabase string `toml:"store-database"` StoreInterval toml.Duration `toml:"store-interval"` }
Config represents the configuration for the monitor service.
func NewConfig ¶
func NewConfig() Config
NewConfig returns an instance of Config with defaults.
func (Config) Diagnostics ¶
func (c Config) Diagnostics() (*diagnostics.Diagnostics, error)
Diagnostics returns a diagnostics representation of a subset of the Config.
func (Config) Validate ¶
Validate validates that the configuration is acceptable.
type Monitor ¶
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 }
Monitor represents an instance of the monitor system.
func New ¶
New returns a new instance of the monitor system.
func (*Monitor) Close ¶
Close closes the monitor system.
func (*Monitor) DeregisterDiagnosticsClient ¶
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) Enabled ¶
Enabled returns true if any underlying Config is Enabled.
func (*Monitor) Open ¶
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 ¶
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 ¶
Statistics returns the combined statistics for all expvar data. The given tags are added to each of the returned statistics.
func (*Monitor) WithLogger ¶
WithLogger sets the logger for the Monitor.
func (*Monitor) WritePoints ¶
WritePoints writes the points the monitor gathers.
type PointsWriter ¶
type PointsWriter interface { WritePoints(database, retentionPolicy string, points models.Points) error }
PointsWriter is a simplified interface for writing the points the monitor gathers.
type RemoteWriterConfig ¶
type RemoteWriterConfig struct { RemoteAddr string NodeID string Username string Password string ClusterID uint64 }
RemoteWriterConfig represents the configuration of a remote writer.
type Reporter ¶
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 }
Reporter is an interface for gathering internal statistics.
type Statistic ¶
Statistic represents the information returned by a single monitor client.
func (*Statistic) ValueNames ¶
ValueNames returns a sorted list of the value names, if any.
type Statistics ¶
type Statistics []*Statistic
Statistics is a slice of sortable statistics.
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.
Source Files ¶
build_info.go config.go go_runtime.go network.go reporter.go service.go system.go
Directories ¶
Path | Synopsis |
---|---|
monitor/diagnostics | Package diagnostics provides the diagnostics type so that other packages can provide diagnostics without depending on the monitor package. |
- Version
- v1.12.0 (latest)
- Published
- Apr 8, 2025
- Platform
- linux/amd64
- Imports
- 15 packages
- Last checked
- 2 days ago –
Tools for package owners.