Documentation
¶
Index ¶
- Constants
- Variables
- func AlignDuration(tm time.Time, interval time.Duration) time.Duration
- func AlignTime(tm time.Time, interval time.Duration) time.Time
- func BasicAuthHandler(username, password, realm string, onError BasicAuthErrorFunc) func(h http.Handler) http.Handler
- func CombinedOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error)
- func CompressWithGzip(data io.Reader) io.ReadCloser
- func ExitStatus(err error) (int, bool)
- func FormatFullVersion() string
- func GenericAuthHandler(credentials string, onError GenericAuthErrorFunc) func(h http.Handler) http.Handler
- func GetProcPath() string
- func GetSysPath() string
- func IPRangeHandler(networks []*net.IPNet, onError ErrorFunc) func(h http.Handler) http.Handler
- func JWTAuthHandler(secret, username string, onError BasicAuthErrorFunc) func(h http.Handler) http.Handler
- func NewGzipReader(r io.Reader) (io.Reader, error)
- func NewStreamContentDecoder(encoding string, r io.Reader) (io.Reader, error)
- func OnClientError(client *http.Client, err error)
- func ParseTimestamp(format string, timestamp interface{}, location *time.Location, ...) (time.Time, error)
- func ProductToken() string
- func RandomDuration(limit time.Duration) time.Duration
- func RandomSleep(limit time.Duration, shutdown chan struct{})
- func RandomString(n int) (string, error)
- func ReadLines(filename string) ([]string, error)
- func RunTimeout(c *exec.Cmd, timeout time.Duration) error
- func SleepContext(ctx context.Context, duration time.Duration) error
- func SnakeCase(in string) string
- func StdOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error)
- func ToBool(value interface{}) (bool, error)
- func ToFloat32(value interface{}) (float32, error)
- func ToFloat64(value interface{}) (float64, error)
- func ToInt16(value interface{}) (int16, error)
- func ToInt32(value interface{}) (int32, error)
- func ToInt64(value interface{}) (int64, error)
- func ToInt8(value interface{}) (int8, error)
- func ToString(value interface{}) (string, error)
- func ToUint16(value interface{}) (uint16, error)
- func ToUint32(value interface{}) (uint32, error)
- func ToUint64(value interface{}) (uint64, error)
- func ToUint8(value interface{}) (uint8, error)
- func WaitTimeout(c *exec.Cmd, timeout time.Duration) error
- type AutoDecoder
- type BasicAuthErrorFunc
- type ContentDecoder
- type ContentEncoder
- type DecodingOption
- type EncodingOption
- type ErrorFunc
- type FatalError
- type GenericAuthErrorFunc
- type GzipDecoder
- type GzipEncoder
- type GzipReader
- type IdentityDecoder
- type IdentityEncoder
- type PartialWriteError
- type ReadWaitCloser
- type StartupError
- type ZlibDecoder
- type ZlibEncoder
- type ZstdDecoder
- type ZstdEncoder
Constants ¶
const Customized = ""
const KillGrace = 5 * time.Second
KillGrace is the amount of time we allow a process to shutdown before sending a SIGKILL.
const NoMetricsCreatedMsg = "No metrics were created from a message. Verify your parser settings. This message is only printed once."
Variables ¶
var ( ErrNotConnected = errors.New("not connected") ErrSerialization = errors.New("serialization of metric(s) failed") ErrSizeLimitReached = errors.New("size limit reached") )
var ( ErrTimeout = errors.New("command timed out") ErrNotImplemented = errors.New("not implemented yet") )
var ( Version = "unknown" Branch = "" Commit = "" )
Set via LDFLAGS -X
var ErrOutOfRange = strconv.ErrRange
var HostEndianness = binary.LittleEndian
Functions ¶
func AlignDuration ¶
AlignDuration returns the duration until next aligned interval. If the current time is aligned a 0 duration is returned.
func AlignTime ¶
AlignTime returns the time of the next aligned interval. If the current time is aligned the current time is returned.
func BasicAuthHandler ¶
func BasicAuthHandler(username, password, realm string, onError BasicAuthErrorFunc) func(h http.Handler) http.Handler
BasicAuthHandler returns a http handler that requires HTTP basic auth credentials to match the given username and password.
func CombinedOutputTimeout ¶
CombinedOutputTimeout runs the given command with the given timeout and returns the combined output of stdout and stderr. If the command times out, it attempts to kill the process.
func CompressWithGzip ¶
func CompressWithGzip(data io.Reader) io.ReadCloser
CompressWithGzip takes an io.Reader as input and pipes it through a gzip.Writer returning an io.Reader containing the gzipped data. Errors occurring during compression are returned to the instance reading from the returned reader via through the corresponding read call (e.g. io.Copy or io.ReadAll).
func ExitStatus ¶
ExitStatus takes the error from exec.Command and returns the exit status and true if error is not exit status, will return 0 and false
func FormatFullVersion ¶
func FormatFullVersion() string
func GenericAuthHandler ¶
func GenericAuthHandler(credentials string, onError GenericAuthErrorFunc) func(h http.Handler) http.Handler
GenericAuthHandler returns a http handler that requires `Authorization: <credentials>`
func GetProcPath ¶
func GetProcPath() string
GetProcPath returns the path stored in HOST_PROC env variable, or /proc if HOST_PROC has not been set.
func GetSysPath ¶
func GetSysPath() string
GetSysPath returns the path stored in HOST_SYS env variable, or /sys if HOST_SYS has not been set.
func IPRangeHandler ¶
IPRangeHandler returns a http handler that requires the remote address to be in the specified network.
func JWTAuthHandler ¶
func JWTAuthHandler(secret, username string, onError BasicAuthErrorFunc) func(h http.Handler) http.Handler
JWTAuthHandler returns a http handler that requires the HTTP bearer auth token to be valid and match the given user.
func NewStreamContentDecoder ¶
NewStreamContentDecoder returns a reader that will decode the stream according to the encoding type.
func OnClientError ¶
func ParseTimestamp ¶
func ParseTimestamp(format string, timestamp interface{}, location *time.Location, separator ...string) (time.Time, error)
ParseTimestamp parses a Time according to the standard Telegraf options. These are generally displayed in the toml similar to:
json_time_key= "timestamp" json_time_format = "2006-01-02T15:04:05Z07:00" json_timezone = "America/Los_Angeles"
The format can be one of "unix", "unix_ms", "unix_us", "unix_ns", or a Go time layout suitable for time.Parse.
When using the "unix" format, an optional fractional component is allowed. Specific unix time precisions cannot have a fractional component.
Unix times may be an int64, float64, or string. When using a Go format string the timestamp must be a string.
The location is a location string suitable for time.LoadLocation. Unix times do not use the location string, a unix time is always return in the UTC location.
func ProductToken ¶
func ProductToken() string
ProductToken returns a tag for Telegraf that can be used in user agents.
func RandomDuration ¶
RandomDuration returns a random duration between 0 and max.
func RandomSleep ¶
RandomSleep will sleep for a random amount of time up to max. If the shutdown channel is closed, it will return before it has finished sleeping.
func RandomString ¶
RandomString returns a random string of alphanumeric characters
func RunTimeout ¶
RunTimeout runs the given command with the given timeout. If the command times out, it attempts to kill the process.
func SleepContext ¶
SleepContext sleeps until the context is closed or the duration is reached.
func SnakeCase ¶
SnakeCase converts the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.
func StdOutputTimeout ¶
StdOutputTimeout runs the given command with the given timeout and returns the output of stdout. If the command times out, it attempts to kill the process.
Types ¶
type AutoDecoder ¶
type AutoDecoder struct {
// contains filtered or unexported fields
}
func NewAutoContentDecoder ¶
func NewAutoContentDecoder(options ...DecodingOption) *AutoDecoder
func (*AutoDecoder) SetEncoding ¶
func (a *AutoDecoder) SetEncoding(encoding string)
type BasicAuthErrorFunc ¶
type BasicAuthErrorFunc func(rw http.ResponseWriter)
type ContentDecoder ¶
ContentDecoder removes a wrapper encoding from byte buffers.
func NewContentDecoder ¶
func NewContentDecoder(encoding string, options ...DecodingOption) (ContentDecoder, error)
NewContentDecoder returns a ContentDecoder for the encoding type.
type ContentEncoder ¶
ContentEncoder applies a wrapper encoding to byte buffers.
func NewContentEncoder ¶
func NewContentEncoder(encoding string, options ...EncodingOption) (ContentEncoder, error)
NewContentEncoder returns a ContentEncoder for the encoding type.
type DecodingOption ¶
type DecodingOption func(*decoderConfig)
DecodingOption provide methods to change the decoding from the standard configuration.
func WithMaxDecompressionSize ¶
func WithMaxDecompressionSize(maxDecompressionSize int64) DecodingOption
type EncodingOption ¶
type EncodingOption func(*encoderConfig)
EncodingOption provide methods to change the encoding from the standard configuration.
func WithCompressionLevel ¶
func WithCompressionLevel(level int) EncodingOption
type ErrorFunc ¶
type ErrorFunc func(rw http.ResponseWriter, code int)
ErrorFunc is a callback for writing an error response.
type FatalError ¶
type FatalError struct {
Err error
}
FatalError indicates a not-recoverable error in the plugin. The corresponding plugin should be remove by the agent stopping any further processing for that plugin instance.
func (*FatalError) Error ¶
func (e *FatalError) Error() string
func (*FatalError) Unwrap ¶
func (e *FatalError) Unwrap() error
type GenericAuthErrorFunc ¶
type GenericAuthErrorFunc func(rw http.ResponseWriter)
type GzipDecoder ¶
type GzipDecoder struct {
// contains filtered or unexported fields
}
GzipDecoder decompresses buffers with gzip compression.
func NewGzipDecoder ¶
func NewGzipDecoder(options ...DecodingOption) *GzipDecoder
func (*GzipDecoder) SetEncoding ¶
func (*GzipDecoder) SetEncoding(string)
type GzipEncoder ¶
type GzipEncoder struct {
// contains filtered or unexported fields
}
GzipEncoder compresses the buffer using gzip at the default level.
func NewGzipEncoder ¶
func NewGzipEncoder(options ...EncodingOption) (*GzipEncoder, error)
type GzipReader ¶
type GzipReader struct {
// contains filtered or unexported fields
}
GzipReader is similar to gzip.Reader but reads only a single gzip stream per read.
type IdentityDecoder ¶
type IdentityDecoder struct {
}
IdentityDecoder is a null decoder that returns the input.
func NewIdentityDecoder ¶
func NewIdentityDecoder(_ ...DecodingOption) *IdentityDecoder
func (*IdentityDecoder) SetEncoding ¶
func (*IdentityDecoder) SetEncoding(string)
type IdentityEncoder ¶
type IdentityEncoder struct{}
IdentityEncoder is a null encoder that applies no transformation.
func NewIdentityEncoder ¶
func NewIdentityEncoder(options ...EncodingOption) (*IdentityEncoder, error)
type PartialWriteError ¶
type PartialWriteError struct {
Err error
MetricsAccept []int
MetricsReject []int
MetricsRejectErrors []error
}
PartialWriteError indicate that only a subset of the metrics were written successfully (i.e. accepted). The rejected metrics should be removed from the buffer without being successfully written. Please note: the metrics are specified as indices into the batch to be able to reference tracking metrics correctly.
func (*PartialWriteError) Error ¶
func (e *PartialWriteError) Error() string
func (*PartialWriteError) Unwrap ¶
func (e *PartialWriteError) Unwrap() error
type ReadWaitCloser ¶
type ReadWaitCloser struct {
// contains filtered or unexported fields
}
func (*ReadWaitCloser) Close ¶
func (r *ReadWaitCloser) Close() error
type StartupError ¶
StartupError indicates an error that occurred during startup of a plugin e.g. due to connectivity issues or resources being not yet available. In case the 'Retry' flag is set, the startup of the plugin might be retried depending on the configured startup-error-behavior. The 'RemovePlugin' flag denotes if the agent should remove the plugin from further processing.
func (*StartupError) Error ¶
func (e *StartupError) Error() string
func (*StartupError) Unwrap ¶
func (e *StartupError) Unwrap() error
type ZlibDecoder ¶
type ZlibDecoder struct {
// contains filtered or unexported fields
}
func NewZlibDecoder ¶
func NewZlibDecoder(options ...DecodingOption) *ZlibDecoder
func (*ZlibDecoder) SetEncoding ¶
func (*ZlibDecoder) SetEncoding(string)
type ZlibEncoder ¶
type ZlibEncoder struct {
// contains filtered or unexported fields
}
func NewZlibEncoder ¶
func NewZlibEncoder(options ...EncodingOption) (*ZlibEncoder, error)
type ZstdDecoder ¶
type ZstdDecoder struct {
// contains filtered or unexported fields
}
func NewZstdDecoder ¶
func NewZstdDecoder(options ...DecodingOption) (*ZstdDecoder, error)
func (*ZstdDecoder) SetEncoding ¶
func (*ZstdDecoder) SetEncoding(string)
type ZstdEncoder ¶
type ZstdEncoder struct {
// contains filtered or unexported fields
}
func NewZstdEncoder ¶
func NewZstdEncoder(options ...EncodingOption) (*ZstdEncoder, error)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package choice provides basic functions for working with plugin options that must be one of several values.
|
Package choice provides basic functions for working with plugin options that must be one of several values. |