beats: github.com/elastic/beats/libbeat/common Index | Files | Directories

package common

import "github.com/elastic/beats/libbeat/common"

Index

Package Files

bytes.go cache.go capabilities_linux.go coerce.go config.go csv.go datetime.go endpoint.go event.go flags.go mapstr.go mapstr_pointer.go math.go net.go statuses.go string.go stringset.go tuples.go url.go version.go

Constants

const (
    FieldsKey = "fields"
    TagsKey   = "tags"
)

Event metadata constants. These keys are used within libbeat to identify metadata stored in an event.

const (
    OK_STATUS           = "OK"
    ERROR_STATUS        = "Error"
    SERVER_ERROR_STATUS = "Server Error"
    CLIENT_ERROR_STATUS = "Client Error"
)

standardized status values

const DefaultDecimalPlacesCount = 4

DefaultDecimalPlacesCount is the default number of decimal places

const MaxIPPortTupleRawSize = 16 + 16 + 2 + 2
const MaxTCPTupleRawSize = 16 + 16 + 2 + 2 + 4
const TsLayout = "2006-01-02T15:04:05.000Z"

TsLayout is the layout to be used in the timestamp marshaling/unmarshaling everywhere. The timezone must always be UTC.

Variables

var (
    // ErrKeyNotFound indicates that the specified key was not found.
    ErrKeyNotFound = errors.New("key not found")
)

func AddTags Uses

func AddTags(ms MapStr, tags []string) error

AddTags appends a tag to the tags field of ms. If the tags field does not exist then it will be created. If the tags field exists and is not a []string then an error will be returned. It does not deduplicate the list of tags.

func AddTagsWithKey Uses

func AddTagsWithKey(ms MapStr, key string, tags []string) error

AddTagsWithKey appends a tag to the key field of ms. If the field does not exist then it will be created. If the field exists and is not a []string then an error will be returned. It does not deduplicate the list.

func BytesHtohl Uses

func BytesHtohl(b []byte) uint32

func BytesNtohl Uses

func BytesNtohl(b []byte) uint32

func BytesNtohll Uses

func BytesNtohll(b []byte) uint64

func BytesNtohs Uses

func BytesNtohs(b []byte) uint16

func ConfigOverwriteFlag Uses

func ConfigOverwriteFlag(
    fs *flag.FlagSet,
    config *Config,
    name, path, def, usage string,
) *string

ConfigOverwriteFlag defines a new flag updating a setting in an Config object. The name is used as the flag its name the path parameter is the full setting name to be used when the flag is set.

func DeDot Uses

func DeDot(s string) string

DeDot a string by replacing all . with _ This helps when sending data to Elasticsearch to prevent object and key collisions.

func DeDotJSON Uses

func DeDotJSON(json interface{}) interface{}

DeDotJSON replaces in keys all . with _ This helps when sending data to Elasticsearch to prevent object and key collisions.

func DumpInCSVFormat Uses

func DumpInCSVFormat(fields []string, rows [][]string) string

DumpInCSVFormat takes a set of fields and rows and returns a string representing the CSV representation for the fields and rows.

func EncodeURLParams Uses

func EncodeURLParams(url string, params url.Values) string

func IPv4Ntoa Uses

func IPv4Ntoa(ip uint32) string

Ipv4_Ntoa transforms an IP4 address in it's dotted notation

func IsLoopback Uses

func IsLoopback(ipStr string) (bool, error)

IsLoopback check if a particular IP notation corresponds to a loopback interface.

func IsStrictPerms Uses

func IsStrictPerms() bool

IsStrictPerms returns true if strict permission checking on config files is enabled.

func LocalIPAddrs Uses

func LocalIPAddrs() ([]net.IP, error)

LocalIPAddrs finds the IP addresses of the hosts on which the shipper currently runs on.

func LocalIPAddrsAsStrings Uses

func LocalIPAddrsAsStrings(includeLoopbacks bool) ([]string, error)

LocalIPAddrsAsStrings finds the IP addresses of the hosts on which the shipper currently runs on and returns them as an array of strings.

func MakeEndpointPair Uses

func MakeEndpointPair(tuple BaseTuple, processTuple *ProcessTuple) (src Endpoint, dst Endpoint)

MakeEndpointPair returns source and destination endpoints from a TCP or IP tuple and a command-line tuple.

func MakeURL Uses

func MakeURL(defaultScheme string, defaultPath string, rawURL string, defaultPort int) (string, error)

MakeURL creates the url based on the url configuration. Adds missing parts with defaults (scheme, host, port)

func MergeFields Uses

func MergeFields(ms, fields MapStr, underRoot bool) error

MergeFields merges the top-level keys and values in each source map (it does not perform a deep merge). If the same key exists in both, the value in fields takes precedence. If underRoot is true then the contents of the fields MapStr is merged with the value of the 'fields' key in ms.

An error is returned if underRoot is true and the value of ms.fields is not a MapStr.

func OverwriteConfigOpts Uses

func OverwriteConfigOpts(options []ucfg.Option)

OverwriteConfigOpts allow to change the globally set config option

func OwnerHasExclusiveWritePerms Uses

func OwnerHasExclusiveWritePerms(name string) error

OwnerHasExclusiveWritePerms asserts that the current user or root is the owner of the config file and that the config file is (at most) writable by the owner or root (e.g. group and other cannot have write access).

func RandomBytes Uses

func RandomBytes(length int) ([]byte, error)

RandomBytes return a slice of random bytes of the defined length

func ReadString Uses

func ReadString(s []byte) (string, error)

ReadString extracts the first null terminated string from a slice of bytes.

func RemoveChars Uses

func RemoveChars(s string, chars string) string

RemoveChars takes a string candidate and a string of chars to remove from the candidate.

func Round Uses

func Round(val float64, precision int64) (newVal float64)

Round rounds the given float64 value and ensures that it has a maximum of "precision" decimal places.

func SettingVarFlag Uses

func SettingVarFlag(fs *flag.FlagSet, def *Config, name, usage string)

SettingVarFlag defines a setting flag, name and it's usage. Settings are applied to the Config object passed.

func TryToFloat64 Uses

func TryToFloat64(number interface{}) (float64, bool)

TryToFloat64 tries to coerce the given interface to an float64. It accepts a float32, float64, or string. On success it returns the float64 value and true.

func TryToInt Uses

func TryToInt(number interface{}) (int, bool)

TryToInt tries to coerce the given interface to an int. On success it returns the int value and true.

type BaseTuple Uses

type BaseTuple struct {
    SrcIP, DstIP     net.IP
    SrcPort, DstPort uint16
}

type Cache Uses

type Cache struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Cache is a semi-persistent mapping of keys to values. Elements added to the cache are store until they are explicitly deleted or are expired due time- based eviction based on last access time.

Expired elements are not visible through classes methods, but they do remain stored in the cache until CleanUp() is invoked. Therefore CleanUp() must be invoked periodically to prevent the cache from becoming a memory leak. If you want to start a goroutine to perform periodic clean-up then see StartJanitor().

Cache does not support storing nil values. Any attempt to put nil into the cache will cause a panic.

func NewCache Uses

func NewCache(d time.Duration, initialSize int) *Cache

NewCache creates and returns a new Cache. d is the length of time after last access that cache elements expire. initialSize is the initial allocation size used for the Cache's underlying map.

func NewCacheWithRemovalListener Uses

func NewCacheWithRemovalListener(d time.Duration, initialSize int, l RemovalListener) *Cache

NewCacheWithRemovalListener creates and returns a new Cache and register a RemovalListener callback function. d is the length of time after last access that cache elements expire. initialSize is the initial allocation size used for the Cache's underlying map. l is the callback function that will be invoked when cache elements are removed from the map on CleanUp.

func (*Cache) CleanUp Uses

func (c *Cache) CleanUp() int

CleanUp performs maintenance on the cache by removing expired elements from the cache. If a RemoveListener is registered it will be invoked for each element that is removed during this clean up operation. The RemovalListener is invoked on the caller's goroutine.

func (*Cache) Delete Uses

func (c *Cache) Delete(k Key) Value

Delete a key from the map and return the value or nil if the key does not exist. The RemovalListener is not notified for explicit deletions.

func (*Cache) Entries Uses

func (c *Cache) Entries() map[Key]Value

Entries returns a shallow copy of the non-expired elements in the cache.

func (*Cache) Get Uses

func (c *Cache) Get(k Key) Value

Get the current value associated with a key or nil if the key is not present. The last access time of the element is updated.

func (*Cache) Put Uses

func (c *Cache) Put(k Key, v Value) Value

Put writes the given key and value to the map replacing any existing value if it exists. The previous value associated with the key returned or nil if the key was not present.

func (*Cache) PutIfAbsent Uses

func (c *Cache) PutIfAbsent(k Key, v Value) Value

PutIfAbsent writes the given key and value to the cache only if the key is absent from the cache. Nil is returned if the key-value pair were written, otherwise the old value is returned.

func (*Cache) PutIfAbsentWithTimeout Uses

func (c *Cache) PutIfAbsentWithTimeout(k Key, v Value, timeout time.Duration) Value

PutIfAbsentWithTimeout writes the given key and value to the cache only if the key is absent from the cache. Nil is returned if the key-value pair were written, otherwise the old value is returned. The cache expiration time will be overwritten by timeout of the key being inserted.

func (*Cache) PutWithTimeout Uses

func (c *Cache) PutWithTimeout(k Key, v Value, timeout time.Duration) Value

PutWithTimeout writes the given key and value to the map replacing any existing value if it exists. The previous value associated with the key returned or nil if the key was not present. The cache expiration time will be overwritten by timeout of the key being inserted.

func (*Cache) Replace Uses

func (c *Cache) Replace(k Key, v Value) Value

Replace overwrites the value for a key only if the key exists. The old value is returned if the value is updated, otherwise nil is returned.

func (*Cache) ReplaceWithTimeout Uses

func (c *Cache) ReplaceWithTimeout(k Key, v Value, timeout time.Duration) Value

ReplaceWithTimeout overwrites the value for a key only if the key exists. The old value is returned if the value is updated, otherwise nil is returned. The cache expiration time will be overwritten by timeout of the key being inserted.

func (*Cache) Size Uses

func (c *Cache) Size() int

Size returns the number of elements in the cache. The number includes both active elements and expired elements that have not been cleaned up.

func (*Cache) StartJanitor Uses

func (c *Cache) StartJanitor(interval time.Duration)

StartJanitor starts a goroutine that will periodically invoke the cache's CleanUp() method.

func (*Cache) StopJanitor Uses

func (c *Cache) StopJanitor()

StopJanitor stops the goroutine created by StartJanitor.

type Capabilities Uses

type Capabilities types.CapabilityInfo

Capabilities contains the capability sets of a process

func GetCapabilities Uses

func GetCapabilities() (Capabilities, error)

GetCapabilities gets the capabilities of this process

func (Capabilities) Check Uses

func (c Capabilities) Check(set []string) bool

Check performs a permission check for a given capabilities set

type Config Uses

type Config ucfg.Config

Config object to store hierarchical configurations into. See https://godoc.org/github.com/elastic/go-ucfg#Config

func LoadFile Uses

func LoadFile(path string) (*Config, error)

func LoadFiles Uses

func LoadFiles(paths ...string) (*Config, error)

func MergeConfigs Uses

func MergeConfigs(cfgs ...*Config) (*Config, error)

func MustNewConfigFrom Uses

func MustNewConfigFrom(from interface{}) *Config

MustNewConfigFrom creates a new Config object from the given input. From can be any kind of structured data (struct, map, array, slice).

If from is a string, the contents is treated like raw YAML input. The string will be parsed and a structure config object is build from the parsed result.

MustNewConfigFrom panics if an error occurs.

func NewConfig Uses

func NewConfig() *Config

func NewConfigFrom Uses

func NewConfigFrom(from interface{}) (*Config, error)

NewConfigFrom creates a new Config object from the given input. From can be any kind of structured data (struct, map, array, slice).

If from is a string, the contents is treated like raw YAML input. The string will be parsed and a structure config object is build from the parsed result.

func NewConfigWithYAML Uses

func NewConfigWithYAML(in []byte, source string) (*Config, error)

func SettingFlag Uses

func SettingFlag(fs *flag.FlagSet, name, usage string) *Config

SettingFlag defines a setting flag, name and it's usage. The return value is the Config object settings are applied to.

func (*Config) Bool Uses

func (c *Config) Bool(name string, idx int) (bool, error)

func (*Config) Child Uses

func (c *Config) Child(name string, idx int) (*Config, error)

func (*Config) CountField Uses

func (c *Config) CountField(name string) (int, error)

func (*Config) Enabled Uses

func (c *Config) Enabled() bool

Enabled return the configured enabled value or true by default.

func (*Config) Float Uses

func (c *Config) Float(name string, idx int) (float64, error)

func (*Config) GetFields Uses

func (c *Config) GetFields() []string

func (*Config) Has Uses

func (c *Config) Has(name string, idx int) (bool, error)

func (*Config) HasField Uses

func (c *Config) HasField(name string) bool

func (*Config) Int Uses

func (c *Config) Int(name string, idx int) (int64, error)

func (*Config) IsArray Uses

func (c *Config) IsArray() bool

func (*Config) IsDict Uses

func (c *Config) IsDict() bool

func (*Config) Merge Uses

func (c *Config) Merge(from interface{}) error

func (*Config) Path Uses

func (c *Config) Path() string

func (*Config) PathOf Uses

func (c *Config) PathOf(field string) string

func (*Config) PrintDebugf Uses

func (c *Config) PrintDebugf(msg string, params ...interface{})

func (*Config) Remove Uses

func (c *Config) Remove(name string, idx int) (bool, error)

func (*Config) SetBool Uses

func (c *Config) SetBool(name string, idx int, value bool) error

func (*Config) SetChild Uses

func (c *Config) SetChild(name string, idx int, value *Config) error

func (*Config) SetFloat Uses

func (c *Config) SetFloat(name string, idx int, value float64) error

func (*Config) SetInt Uses

func (c *Config) SetInt(name string, idx int, value int64) error

func (*Config) SetString Uses

func (c *Config) SetString(name string, idx int, value string) error

func (*Config) String Uses

func (c *Config) String(name string, idx int) (string, error)

func (*Config) Unpack Uses

func (c *Config) Unpack(to interface{}) error

type ConfigNamespace Uses

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

ConfigNamespace storing at most one configuration section by name and sub-section.

func (*ConfigNamespace) Config Uses

func (ns *ConfigNamespace) Config() *Config

Config return the sub-configuration section if a section has been set.

func (*ConfigNamespace) IsSet Uses

func (ns *ConfigNamespace) IsSet() bool

IsSet returns true if a sub-configuration section has been set.

func (*ConfigNamespace) Name Uses

func (ns *ConfigNamespace) Name() string

Name returns the configuration sections it's name if a section has been set.

func (*ConfigNamespace) Unpack Uses

func (ns *ConfigNamespace) Unpack(cfg *Config) error

Unpack unpacks a configuration with at most one sub object. An sub object is ignored if it is disabled by setting `enabled: false`. If the configuration passed contains multiple active sub objects, Unpack will return an error.

type Endpoint Uses

type Endpoint struct {
    IP     string
    Port   uint16
    Domain string

    // Process metadata.
    Process
}

Endpoint represents an endpoint in the communication.

type EventMetadata Uses

type EventMetadata struct {
    Fields          MapStr
    FieldsUnderRoot bool `config:"fields_under_root"`
    Tags            []string
}

EventMetadata contains fields and tags that can be added to an event via configuration.

type Float Uses

type Float float64

func (Float) MarshalJSON Uses

func (f Float) MarshalJSON() ([]byte, error)

Defines the marshal of the Float type

type HashableIPPortTuple Uses

type HashableIPPortTuple [MaxIPPortTupleRawSize]byte

type HashableTCPTuple Uses

type HashableTCPTuple [MaxTCPTupleRawSize]byte

type IPPortTuple Uses

type IPPortTuple struct {
    BaseTuple

    IPLength int
    // contains filtered or unexported fields
}

func NewIPPortTuple Uses

func NewIPPortTuple(ipLength int, srcIP net.IP, srcPort uint16,
    dstIP net.IP, dstPort uint16) IPPortTuple

func (*IPPortTuple) ComputeHashables Uses

func (t *IPPortTuple) ComputeHashables()

func (*IPPortTuple) Hashable Uses

func (t *IPPortTuple) Hashable() HashableIPPortTuple

Hashable returns a hashable value that uniquely identifies the IP-port tuple.

func (*IPPortTuple) RevHashable Uses

func (t *IPPortTuple) RevHashable() HashableIPPortTuple

Hashable returns a hashable value that uniquely identifies the IP-port tuple after swapping the source and destination.

func (*IPPortTuple) String Uses

func (t *IPPortTuple) String() string

type Key Uses

type Key interface{}

Key type used in the cache.

type MapStr Uses

type MapStr map[string]interface{}

MapStr is a map[string]interface{} wrapper with utility methods for common map operations like converting to JSON.

func ConvertToGenericEvent Uses

func ConvertToGenericEvent(m MapStr) MapStr

ConvertToGenericEvent normalizes the types contained in the given MapStr.

Nil values in maps are dropped during the conversion. Any unsupported types that are found in the MapStr are dropped and warnings are logged.

func MapStrUnion Uses

func MapStrUnion(dict1 MapStr, dict2 MapStr) MapStr

MapStrUnion creates a new MapStr containing the union of the key-value pairs of the two maps. If the same key is present in both, the key-value pairs from dict2 overwrite the ones from dict1.

func (MapStr) Clone Uses

func (m MapStr) Clone() MapStr

Clone returns a copy of the MapStr. It recursively makes copies of inner maps.

func (MapStr) CopyFieldsTo Uses

func (m MapStr) CopyFieldsTo(to MapStr, key string) error

CopyFieldsTo copies the field specified by key to the given map. It will overwrite the key if it exists. An error is returned if the key does not exist in the source map.

func (MapStr) DeepUpdate Uses

func (m MapStr) DeepUpdate(d MapStr)

DeepUpdate recursively copies the key-value pairs from d to this map. If the key is present and a map as well, the sub-map will be updated recursively via DeepUpdate.

func (MapStr) Delete Uses

func (m MapStr) Delete(key string) error

Delete deletes the given key from the map.

func (MapStr) Flatten Uses

func (m MapStr) Flatten() MapStr

Flatten flattens the given MapStr and returns a flat MapStr.

Example:

"hello": MapStr{"world": "test" }

This is converted to:

"hello.world": "test"

This can be useful for testing or logging.

func (MapStr) GetValue Uses

func (m MapStr) GetValue(key string) (interface{}, error)

GetValue gets a value from the map. If the key does not exist then an error is returned.

func (MapStr) HasKey Uses

func (m MapStr) HasKey(key string) (bool, error)

HasKey returns true if the key exist. If an error occurs then false is returned with a non-nil error.

func (MapStr) MarshalLogObject Uses

func (m MapStr) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface and allows for more efficient marshaling of MapStr in structured logging.

func (MapStr) Put Uses

func (m MapStr) Put(key string, value interface{}) (interface{}, error)

Put associates the specified value with the specified key. If the map previously contained a mapping for the key, the old value is replaced and returned. The key can be expressed in dot-notation (e.g. x.y) to put a value into a nested map.

If you need insert keys containing dots then you must use bracket notation to insert values (e.g. m[key] = value).

func (MapStr) String Uses

func (m MapStr) String() string

String returns the MapStr as JSON.

func (MapStr) StringToPrint Uses

func (m MapStr) StringToPrint() string

StringToPrint returns the MapStr as pretty JSON.

func (MapStr) Update Uses

func (m MapStr) Update(d MapStr)

Update copies all the key-value pairs from d to this map. If the key already exists then it is overwritten. This method does not merge nested maps.

type MapStrPointer Uses

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

MapStrPointer stores a pointer to atomically get/set a MapStr object This should give faster access for use cases with lots of reads and a few changes. It's important to note that modifying the map is not thread safe, only fully replacing it.

func NewMapStrPointer Uses

func NewMapStrPointer(m MapStr) MapStrPointer

NewMapStrPointer initializes and returns a pointer to the given MapStr

func (MapStrPointer) Get Uses

func (m MapStrPointer) Get() MapStr

Get returns the MapStr stored under this pointer

func (*MapStrPointer) Set Uses

func (m *MapStrPointer) Set(p MapStr)

Set stores a pointer the given MapStr, replacing any previous one

type NetString Uses

type NetString []byte

NetString store the byte length of the data that follows, making it easier to unambiguously pass text and byte data between programs that could be sensitive to values that could be interpreted as delimiters or terminators (such as a null character).

func (NetString) MarshalText Uses

func (n NetString) MarshalText() ([]byte, error)

MarshalText exists to implement encoding.TextMarshaller interface to treat []byte as raw string by other encoders/serializers (e.g. JSON)

type Process Uses

type Process struct {
    PID       int       // Process ID.
    PPID      int       // Parent process ID.
    Name      string    // Name of process (or alias given by cmdline_grep config).
    Args      []string  // Process arguments.
    Exe       string    // Absolute path to exe.
    CWD       string    // Current working directory.
    StartTime time.Time // Start time of process.
}

Process contains process information.

type ProcessTuple Uses

type ProcessTuple struct {
    Src, Dst Process
}

ProcessTuple contains the source and destination process names, as found by the proc module.

func (*ProcessTuple) Reverse Uses

func (c *ProcessTuple) Reverse() ProcessTuple

Reverse returns a copy of the receiver with the source and destination fields swapped.

type RemovalListener Uses

type RemovalListener func(k Key, v Value)

RemovalListener is the callback function type that can be registered with the cache to receive notification of the removal of expired elements.

type SettingsFlag Uses

type SettingsFlag cfgflag.FlagValue

SettingsFlag captures key/values pairs into an Config object. The flag backed by SettingsFlag can be used multiple times. Values are overwritten by the last usage of a key.

func NewSettingsFlag Uses

func NewSettingsFlag(def *Config) *SettingsFlag

NewSettingsFlag creates a new SettingsFlag instance, not registered with any FlagSet.

func (*SettingsFlag) Config Uses

func (f *SettingsFlag) Config() *Config

Config returns the config object the SettingsFlag stores applied settings to.

func (*SettingsFlag) Get Uses

func (f *SettingsFlag) Get() interface{}

Get returns the Config object used to store values.

func (*SettingsFlag) Set Uses

func (f *SettingsFlag) Set(s string) error

Set sets a settings value in the Config object. The input string must be a key-value pair like `key=value`. If the value is missing, the value is set to the boolean value `true`.

func (*SettingsFlag) String Uses

func (f *SettingsFlag) String() string

String always returns an empty string. It is required to fulfil the flag.Value interface.

func (*SettingsFlag) Type Uses

func (f *SettingsFlag) Type() string

Type reports the type of contents (setting=value) expected to be parsed by Set. It is used to build the CLI usage string.

type StringSet Uses

type StringSet map[string]struct{}

func MakeStringSet Uses

func MakeStringSet(strings ...string) StringSet

func (StringSet) Add Uses

func (set StringSet) Add(s string)

func (StringSet) Count Uses

func (set StringSet) Count() int

func (StringSet) Del Uses

func (set StringSet) Del(s string)

func (StringSet) Equals Uses

func (set StringSet) Equals(anotherSet StringSet) bool

Equals compares this StringSet with another StringSet.

func (StringSet) Has Uses

func (set StringSet) Has(s string) (exists bool)

func (StringSet) ToSlice Uses

func (set StringSet) ToSlice() []string

ToSlice returns the items in the set as a sorted slice.

type StringsFlag Uses

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

StringsFlag collects multiple usages of the same flag into an array of strings. Duplicate values will be ignored.

func NewStringsFlag Uses

func NewStringsFlag(arr *[]string) *StringsFlag

NewStringsFlag creates a new, but unregistered StringsFlag instance. Results of the flag usage will be appended to `arr`. If the slice is not initially empty, its first value will be used as default. If the flag is used, the slice will be emptied first.

func StringArrFlag Uses

func StringArrFlag(fs *flag.FlagSet, name, def, usage string) *StringsFlag

StringArrFlag creates and registers a new StringsFlag with the given FlagSet. If no FlagSet is passed, flag.CommandLine will be used as target FlagSet.

func StringArrVarFlag Uses

func StringArrVarFlag(fs *flag.FlagSet, arr *[]string, name, usage string) *StringsFlag

StringArrVarFlag creates and registers a new StringsFlag with the given FlagSet. Results of the flag usage will be appended to `arr`. If the slice is not initially empty, its first value will be used as default. If the flag is used, the slice will be emptied first. If no FlagSet is passed, flag.CommandLine will be used as target FlagSet.

func (*StringsFlag) Get Uses

func (f *StringsFlag) Get() interface{}

Get returns the backing slice its contents as interface{}. The type used is `[]string`.

func (*StringsFlag) List Uses

func (f *StringsFlag) List() []string

List returns the current set values.

func (*StringsFlag) Register Uses

func (f *StringsFlag) Register(fs *flag.FlagSet, name, usage string)

Register registers the StringsFlag instance with a FlagSet. A valid FlagSet must be used. Register panics if the flag is already registered.

func (*StringsFlag) Set Uses

func (f *StringsFlag) Set(v string) error

Set is used to pass usage of the flag to StringsFlag. Set adds the new value to the backing array. The array will be emptied on Set, if the backing array still contains the default value.

func (*StringsFlag) SetDefault Uses

func (f *StringsFlag) SetDefault(v string)

SetDefault sets the flags new default value. This overwrites the contents in the backing array.

func (*StringsFlag) String Uses

func (f *StringsFlag) String() string

String joins all it's values set into a comma-separated string.

func (*StringsFlag) Type Uses

func (f *StringsFlag) Type() string

Type reports the type of contents (string) expected to be parsed by Set. It is used to build the CLI usage string.

type TCPTuple Uses

type TCPTuple struct {
    BaseTuple
    IPLength int

    StreamID uint32
    // contains filtered or unexported fields
}

func TCPTupleFromIPPort Uses

func TCPTupleFromIPPort(t *IPPortTuple, streamID uint32) TCPTuple

func (*TCPTuple) ComputeHashables Uses

func (t *TCPTuple) ComputeHashables()

func (*TCPTuple) Hashable Uses

func (t *TCPTuple) Hashable() HashableTCPTuple

Hashable() returns a hashable value that uniquely identifies the TCP tuple.

func (TCPTuple) IPPort Uses

func (t TCPTuple) IPPort() *IPPortTuple

Returns a pointer to the equivalent IpPortTuple.

func (TCPTuple) String Uses

func (t TCPTuple) String() string

type Time Uses

type Time time.Time

Time is an abstraction for the time.Time type

func MustParseTime Uses

func MustParseTime(timespec string) Time

MustParseTime is a convenience equivalent of the ParseTime function that panics in case of errors.

func ParseTime Uses

func ParseTime(timespec string) (Time, error)

ParseTime parses a time in the TsLayout format.

func (Time) Hash32 Uses

func (t Time) Hash32(h hash.Hash32) error

func (Time) MarshalJSON Uses

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface. The time is a quoted string in the JsTsLayout format.

func (Time) String Uses

func (t Time) String() string

func (*Time) UnmarshalJSON Uses

func (t *Time) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements js.Unmarshaler interface. The time is expected to be a quoted string in TsLayout format.

type Value Uses

type Value interface{}

Value type held in the cache. Cannot be nil.

type Version Uses

type Version struct {
    Major  int
    Minor  int
    Bugfix int
    Meta   string
    // contains filtered or unexported fields
}

func MustNewVersion Uses

func MustNewVersion(version string) *Version

MustNewVersion creates a version from the given version string. If the version string is invalid, MustNewVersion panics.

func NewVersion Uses

func NewVersion(version string) (*Version, error)

NewVersion expects a string in the format: major.minor.bugfix(-meta)

func (*Version) IsMajor Uses

func (v *Version) IsMajor(major int) bool

func (*Version) IsValid Uses

func (v *Version) IsValid() bool

IsValid returns true if the version object stores a successfully parsed version number.

func (*Version) LessThan Uses

func (v *Version) LessThan(v1 *Version) bool

LessThan returns true if v is strictly smaller than v1. When comparing, the major, minor and bugfix numbers are compared in order. The meta part is not taken into account.

func (*Version) LessThanOrEqual Uses

func (v *Version) LessThanOrEqual(withMeta bool, v1 *Version) bool

LessThan returns true if v is strictly smaller than v1. When comparing, the major, minor, bugfix and pre-release numbers are compared in order.

func (*Version) String Uses

func (v *Version) String() string

func (*Version) UnmarshalJSON Uses

func (v *Version) UnmarshalJSON(version []byte) error

UnmarshalJSON unmarshals a JSON string version representation into a Version struct Implements https://golang.org/pkg/encoding/json/#Unmarshaler

Directories

PathSynopsis
atomicPackage atomic provides common primitive types with atomic accessors.
backoff
bus
cfgtype
cfgwarn
cleanupPackage cleanup provides common helpers for common cleanup patterns on defer
cli
docker
dtfmtPackage dtfmt provides time formatter support with pattern syntax mostly similar to joda DateTimeFormat.
file
flowhashPackage flowhash provides the ability to hash flows.
flowhash/examples
fmtstr
jsontransform
kafka
kubernetes
mapvalPackage mapval is used to validate JSON-like nested map data-structure against a set of expectations.
match
op
reload
safemapstr
schemaPackage schema contains helper utilities to parse, convert, rename, and reorganize data from the format returned by the various monitored systems to the data model used by Metricbeat.
schema/mapstrifacePackage mapstriface contains utilities for transforming map[string]interface{} objects into metricbeat events.
schema/mapstrstrPackage mapstrstr contains utilities for transforming map[string]string objects into metricbeat events.
seccomp
streambufPackage streambuf provides helpers for buffering multiple packet payloads and some general parsing functions.
terminal
transport/tlscommon
x509util

Package common imports 36 packages (graph) and is imported by 5036 packages. Updated 2019-09-12. Refresh now. Tools for package owners.