graphite - ActiveState ActiveGo 1.8
...

Package graphite

import "github.com/influxdata/influxdb/services/graphite"
Overview
Index

Overview ▾

Package graphite provides a service for InfluxDB to ingest data via the graphite protocol.

Constants

const (
    // DefaultBindAddress is the default binding interface if none is specified.
    DefaultBindAddress = ":2003"

    // DefaultDatabase is the default database if none is specified.
    DefaultDatabase = "graphite"

    // DefaultProtocol is the default IP protocol used by the Graphite input.
    DefaultProtocol = "tcp"

    // DefaultConsistencyLevel is the default write consistency for the Graphite input.
    DefaultConsistencyLevel = "one"

    // DefaultSeparator is the default join character to use when joining multiple
    // measurement parts in a template.
    DefaultSeparator = "."

    // DefaultBatchSize is the default write batch size.
    DefaultBatchSize = 5000

    // DefaultBatchPending is the default number of pending write batches.
    DefaultBatchPending = 10

    // DefaultBatchTimeout is the default Graphite batch timeout.
    DefaultBatchTimeout = time.Second

    // DefaultUDPReadBuffer is the default buffer size for the UDP listener.
    // Sets the size of the operating system's receive buffer associated with
    // the UDP traffic. Keep in mind that the OS must be able
    // to handle the number set here or the UDP listener will error and exit.
    //
    // DefaultReadBuffer = 0 means to use the OS default, which is usually too
    // small for high UDP performance.
    //
    // Increasing OS buffer limits:
    //     Linux:      sudo sysctl -w net.core.rmem_max=<read-buffer>
    //     BSD/Darwin: sudo sysctl -w kern.ipc.maxsockbuf=<read-buffer>
    DefaultUDPReadBuffer = 0
)

Variables

Minimum and maximum supported dates for timestamps.

var (
    // The minimum graphite timestamp allowed.
    MinDate = time.Date(1901, 12, 13, 0, 0, 0, 0, time.UTC)

    // The maximum graphite timestamp allowed.
    MaxDate = time.Date(2038, 1, 19, 0, 0, 0, 0, time.UTC)
)

func NewTemplate

func NewTemplate(pattern string, defaultTags models.Tags, separator string) (*template, error)

NewTemplate returns a new template ensuring it has a measurement specified.

type Config

Config represents the configuration for Graphite endpoints.

type Config struct {
    Enabled          bool          `toml:"enabled"`
    BindAddress      string        `toml:"bind-address"`
    Database         string        `toml:"database"`
    RetentionPolicy  string        `toml:"retention-policy"`
    Protocol         string        `toml:"protocol"`
    BatchSize        int           `toml:"batch-size"`
    BatchPending     int           `toml:"batch-pending"`
    BatchTimeout     toml.Duration `toml:"batch-timeout"`
    ConsistencyLevel string        `toml:"consistency-level"`
    Templates        []string      `toml:"templates"`
    Tags             []string      `toml:"tags"`
    Separator        string        `toml:"separator"`
    UDPReadBuffer    int           `toml:"udp-read-buffer"`
}

func NewConfig

func NewConfig() Config

NewConfig returns a new instance of Config with defaults.

func (*Config) DefaultTags

func (c *Config) DefaultTags() models.Tags

DefaultTags returns the config's tags.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config's templates and tags.

func (*Config) WithDefaults

func (c *Config) WithDefaults() *Config

WithDefaults takes the given config and returns a new config with any required default values set.

type Options

Options are configurable values that can be provided to a Parser.

type Options struct {
    Separator   string
    Templates   []string
    DefaultTags models.Tags
}

type Parser

Parser encapsulates a Graphite Parser.

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

func NewParser

func NewParser(templates []string, defaultTags models.Tags) (*Parser, error)

NewParser returns a GraphiteParser instance.

func NewParserWithOptions

func NewParserWithOptions(options Options) (*Parser, error)

NewParserWithOptions returns a graphite parser using the given options.

func (*Parser) ApplyTemplate

func (p *Parser) ApplyTemplate(line string) (string, map[string]string, string, error)

ApplyTemplate extracts the template fields from the given line and returns the measurement name and tags.

func (*Parser) Parse

func (p *Parser) Parse(line string) (models.Point, error)

Parse performs Graphite parsing of a single line.

type Service

Service represents a Graphite service.

type Service struct {
    Monitor interface {
        RegisterDiagnosticsClient(name string, client diagnostics.Client)
        DeregisterDiagnosticsClient(name string)
    }
    PointsWriter interface {
        WritePoints(database, retentionPolicy string, consistencyLevel models.ConsistencyLevel, points []models.Point) error
    }
    MetaClient interface {
        CreateDatabase(name string) (*meta.DatabaseInfo, error)
        CreateDatabaseWithRetentionPolicy(name string, spec *meta.RetentionPolicySpec) (*meta.DatabaseInfo, error)
        CreateRetentionPolicy(database string, spec *meta.RetentionPolicySpec, makeDefault bool) (*meta.RetentionPolicyInfo, error)
        Database(name string) *meta.DatabaseInfo
        RetentionPolicy(database, name string) (*meta.RetentionPolicyInfo, error)
    }
    // contains filtered or unexported fields
}

func NewService

func NewService(c Config) (*Service, error)

NewService returns an instance of the Graphite service.

func (*Service) Addr

func (s *Service) Addr() net.Addr

Addr returns the address the Service binds to.

func (*Service) Close

func (s *Service) Close() error

Close stops all data processing on the Graphite input.

func (*Service) Closed

func (s *Service) Closed() bool

Closed returns true if the service is currently closed.

func (*Service) Diagnostics

func (s *Service) Diagnostics() (*diagnostics.Diagnostics, error)

Diagnostics returns diagnostics of the graphite service.

func (*Service) Open

func (s *Service) Open() error

Open starts the Graphite input processing data.

func (*Service) Statistics

func (s *Service) Statistics(tags map[string]string) []models.Statistic

Statistics returns statistics for periodic monitoring.

func (*Service) WithLogger

func (s *Service) WithLogger(log zap.Logger)

WithLogger sets the logger on the service.

type Statistics

Statistics maintains statistics for the graphite service.

type Statistics struct {
    PointsReceived      int64
    BytesReceived       int64
    PointsParseFail     int64
    PointsNaNFail       int64
    BatchesTransmitted  int64
    PointsTransmitted   int64
    BatchesTransmitFail int64
    ActiveConnections   int64
    HandledConnections  int64
}

type UnsupportedValueError

An UnsupportedValueError is returned when a parsed value is not supported.

type UnsupportedValueError struct {
    Field string
    Value float64
}

func (*UnsupportedValueError) Error

func (err *UnsupportedValueError) Error() string