Documentation ¶
Index ¶
- type Agent
- type Aggregate
- type Base64Decode
- type Base64Encode
- type ConvertTime
- type Copy
- type Delete
- type Double
- type Envelope
- type Flatten
- type GeoIP
- type Grok
- type Hostname
- type Identifier
- type JSON
- type Move
- type RegExp
- type Replace
- type Runlength
- type Sequence
- type Split
- type SplitPick
- type SplitToFields
- type StreamName
- type StreamRevert
- type StreamRoute
- type Template
- type Timestamp
- type ToCSV
- type ToJSON
- type Trim
- type TrimToBounds
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Agent formatter
This formatter parses a user agent string and outputs it as metadata fields to the set target.
Parameters ¶
- Fields: An array of the fields to extract from the user agent. Available fields are: "mozilla", "platform", "os", "localization", "engine", "engine-version", "browser", "browser-version", "bot", "mobile". By default this is set to ["platform","os","localization","browser"].
- Prefix: Defines a prefix for each of the keys generated. By default this is set to "".
Examples
exampleConsumer: Type: consumer.Console Streams: stdin Modulators: - format.Agent Source: user_agent
func (*Agent) ApplyFormatter ¶
ApplyFormatter update message payload
func (*Agent) Configure ¶
func (format *Agent) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Aggregate ¶ added in v0.5.0
type Aggregate struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Aggregate formatter plugin
Aggregate is a formatter which can group up further formatter. The `Source` setting will be passed on to all child formatters, overwriting any source value there (if set). This plugin could be useful to setup complex configs with metadata handling in more readable format.
Parameters ¶
- Source: This value chooses the part of the message that should be formatted. Use "" to use the message payload; other values specify the name of a metadata field to use. This values is forced to be used by all child modulators. By default this parameter is set to "".
- Modulators: Defines a list of child modulators to be applied to a message when it arrives at this formatter. Please note that everything is still one message. I.e. applying filters twice might not make sense.
Examples ¶
This example show a useful case for format.Aggregate plugin:
exampleConsumerA: Type: consumer.Console Streams: "foo" Modulators: - format.Aggregate: Target: bar Modulators: - format.Copy - format.Envelope: Postfix: "\n" - format.Aggregate: Target: foo Modulators: - format.Copy - format.Base64Encode - format.Double - format.Envelope: Postfix: "\n" # same config as exampleConsumerB: Type: consumer.Console Streams: "bar" Modulators: - format.Copy: Target: bar - format.Envelope: Target: bar Postfix: "\n" - format.Copy: Target: foo - format.Base64Encode: Target: foo - format.Double: Target: foo - format.Envelope: Postfix: "\n" Target: foo
func (*Aggregate) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter execute the formatter
func (*Aggregate) Configure ¶ added in v0.5.0
func (format *Aggregate) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Base64Decode ¶
type Base64Decode struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Base64Decode formatter plugin
Base64Decode is a formatter that decodes base64 encoded messages. If a message is not or only partly base64 encoded an error will be logged and the decoded part is returned. RFC 4648 is expected.
Parameters ¶
- Base64Dictionary: This value defines the 64-character base64 lookup dictionary to use. When left empty, a dictionary as defined by RFC4648 is used. By default this parameter is set to "".
Examples ¶
This example expects base64 strings from the console and decodes them before transmitting the message payload.
exampleConsumer: Type: consumer.Console Streams: "*" Modulators: - format.Base64Decode
func (*Base64Decode) ApplyFormatter ¶ added in v0.5.0
func (format *Base64Decode) ApplyFormatter(msg *core.Message) error
ApplyFormatter execute the formatter
func (*Base64Decode) Configure ¶
func (format *Base64Decode) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Base64Encode ¶
type Base64Encode struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Base64Encode formatter
Base64Encode is a formatter that decodes Base64 encoded strings. Custom dictionaries are supported, by default RFC 4648 standard encoding is used.
Parameters ¶
- Base64Dictionary: Defines the 64-character base64 lookup dictionary to use. When left empty a RFC 4648 standard encoding is used. By default this parameter is set to "".
Examples ¶
This example uses RFC 4648 URL encoding to format incoming data.
ExampleConsumer: Type: consumer.Console Streams: console Modulators: - formatter.Base64Encode Dictionary: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
func (*Base64Encode) ApplyFormatter ¶ added in v0.5.0
func (format *Base64Encode) ApplyFormatter(msg *core.Message) error
ApplyFormatter update message payload
func (*Base64Encode) Configure ¶
func (format *Base64Encode) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type ConvertTime ¶
type ConvertTime struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
ConvertTime formatter
This formatter converts one time format in another.
- From: When left empty, a unix time is expected. Otherwise a go compatible timestamp has to be given. See https://golang.org/pkg/time/#pkg-constants By default this is set to "".
- To: When left empty, the output will be unixtime. Otherwise a go compatible timestamp has to be given. See https://golang.org/pkg/time/#pkg-constants By default this is set to "".
Examples ¶
This example removes the "pipe" key from the metadata produced by consumer.Console.
exampleConsumer: Type: consumer.Console Streams: stdin Modulators: - format.ConvertTime: FromFormat: "" ToFormat: ""
func (*ConvertTime) ApplyFormatter ¶
func (format *ConvertTime) ApplyFormatter(msg *core.Message) error
ApplyFormatter update message payload
func (*ConvertTime) Configure ¶
func (format *ConvertTime) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Copy ¶
type Copy struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Copy formatter plugin
This formatter sets metadata fields by copying data from the message's payload or from other metadata fields.
Parameters ¶
- Source: Defines the key to copy, i.e. the "source" of a copy operation. Target will define the target of the copy, i.e. the "destination". An empty string will use the message payload as source. By default this parameter is set to an empty string (i.e. payload).
- Mode: Defines the copy mode to use. This can be one of "append", "prepend" or "replace". By default this parameter is set to "replace".
- Separator: When using mode prepend or append, defines the characters inserted between source and destination. By default this parameter is set to an empty string.
Examples ¶
This example copies the payload to the field key and applies a hash on it contain a hash over the complete payload.
exampleConsumer: Type: consumer.Console Streams: "*" Modulators: - format.Copy: Target: key - formatter.Identifier Generator: hash Target: key
func (*Copy) ApplyFormatter ¶
ApplyFormatter update message payload
func (*Copy) Configure ¶
func (format *Copy) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Delete ¶
type Delete struct {
core.SimpleFormatter `gollumdoc:"embed_type"`
}
Delete formatter
This formatter erases the message payload or deletes a metadata key.
Examples ¶
This example removes the "pipe" key from the metadata produced by consumer.Console.
exampleConsumer: Type: consumer.Console Streams: stdin Modulators: - format.Delete Target: pipe
func (*Delete) ApplyFormatter ¶
ApplyFormatter update message payload
func (*Delete) Configure ¶
func (format *Delete) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Double ¶ added in v0.5.0
type Double struct { core.SimpleFormatter `gollumdoc:"embed_type"` Target string // contains filtered or unexported fields }
Double formatter plugin
Double is a formatter that duplicates a message and applies two different sets of formatters to both sides. After both messages have been processed, the value of the field defined as "source" by the double formatter will be copied from both copies and merged into the "target" field of the original message using a given separator.
Parameters ¶
- Separator: This value sets the separator string placed between both parts. This parameter is set to ":" by default.
- UseLeftStreamID: When set to "true", use the stream id of the left side (after formatting) as the streamID for the resulting message. This parameter is set to "false" by default.
- Left: An optional list of formatters. The first copy of the message (left of the delimiter) is passed through these filters. This parameter is set to an empty list by default.
- Right: An optional list of formatters. The second copy of the mssage (right of the delimiter) is passed through these filters. This parameter is set to an empty list by default.
Examples ¶
This example creates a message of the form "<orig>|<hash>", where <orig> is the original console input and <hash> its hash.
exampleConsumer: Type: consumer.Console Streams: "*" Modulators: - format.Double: Separator: "|" Right: - format.Identifier: Generator: hash
func (*Double) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter update message payload
func (*Double) Configure ¶ added in v0.5.0
func (format *Double) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Envelope ¶
type Envelope struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Envelope formatter
This formatter adds content to the beginning and/or end of a message.
Parameters ¶
- Prefix: Defines a string that is added to the front of the message. Special characters like \n \r or \t can be used without additional escaping. By default this parameter is set to "".
- Postfix: Defines a string that is added to the end of the message. Special characters like \n \r or \t can be used without additional escaping. By default this parameter is set to "\n".
Examples ¶
This example adds a line number and a newline character to each message printed to the console.
exampleProducer: Type: producer.Console Streams: "*" Modulators: - format.Sequence - format.Envelope
func (*Envelope) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter update message payload
func (*Envelope) Configure ¶
func (format *Envelope) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Flatten ¶
type Flatten struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Flatten formatter
This formatter takes a metadata tree and moves all subkeys on the same level as the root of the tree. Fields will be named according to their hierarchy but joining all keys in the path with a given separator.
Parameters ¶
- Separator: Defines the separator used when joining keys. By default this parameter is set to "."
Examples ¶
This will flatten all elements below the key "tree" on the root level. A key `/tree/a/b` will become `/tree.a.b`
ExampleConsumer: Type: consumer.Console Streams: console Modulators: - format.Flatten: Source: tree
func (*Flatten) ApplyFormatter ¶
ApplyFormatter update message payload
func (*Flatten) Configure ¶
func (format *Flatten) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type GeoIP ¶
type GeoIP struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
GeoIP formatter
This formatter parses an IP and outputs it's geo information as metadata fields to the set target.
Parameters ¶
- GeoIPFile: Defines a GeoIP file to load this setting is mandatory. Files can be found e.g. at http://dev.maxmind.com/geoip/geoip2/geolite2/. By default this parameter is set to "".
- Fields: An array of the fields to extract from the GeoIP. Available fields are: "city", "country-code", "country", "continent-code", "continent", "timezone", "proxy", "satellite", "location", "location-hash" By default this is set to ["city","country","continent","location-hash"].
- Prefix: Defines a prefix for each of the keys generated. By default this is set to "".
Examples
exampleConsumer: Type: consumer.Console Streams: stdin Modulators: - format.GeoIP Source: client-ip
func (*GeoIP) ApplyFormatter ¶
ApplyFormatter update message payload
func (*GeoIP) Configure ¶
func (format *GeoIP) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Grok ¶
type Grok struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Grok formatter plugin
Grok is a formatter that applies regex filters to messages and stores the result as metadata fields. If the target key is not existing it will be created. If the target key is existing but not a map, it will be replaced. It works by combining text patterns into something that matches your logs. See https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html#_grok_basics for more information about Grok.
Parameters ¶
- RemoveEmptyValues: When set to true, empty captures will not be returned. By default this parameter is set to "true".
- NamedCapturesOnly: When set to true, only named captures will be returned. By default this parameter is set to "true".
- SkipDefaultPatterns: When set to true, standard grok patterns will not be included in the list of patterns. By default this parameter is set to "true".
- Patterns: A list of grok patterns that will be applied to messages. The first matching pattern will be used to parse the message.
Examples ¶
This example transforms unstructured input into a structured json output. Input:
us-west.servicename.webserver0.this.is.the.measurement 12.0 1497003802
Output:
{ "datacenter": "us-west", "service": "servicename", "host": "webserver0", "measurement": "this.is.the.measurement", "value": "12.0", "time": "1497003802" }
Config:
exampleConsumer: Type: consumer.Console Streams: "*" Modulators: - format.Grok: Patterns: - ^(?P<datacenter>[^\.]+?)\.(?P<service>[^\.]+?)\.(?P<host>[^\.]+?)\.statsd\.gauge-(?P<application>[^\.]+?)\.(?P<measurement>[^\s]+?)\s%{NUMBER:value_gauge:float}\s*%{INT:time} - ^(?P<datacenter>[^\.]+?)\.(?P<service>[^\.]+?)\.(?P<host>[^\.]+?)\.statsd\.latency-(?P<application>[^\.]+?)\.(?P<measurement>[^\s]+?)\s%{NUMBER:value_latency:float}\s*%{INT:time} - ^(?P<datacenter>[^\.]+?)\.(?P<service>[^\.]+?)\.(?P<host>[^\.]+?)\.statsd\.derive-(?P<application>[^\.]+?)\.(?P<measurement>[^\s]+?)\s%{NUMBER:value_derive:float}\s*%{INT:time} - ^(?P<datacenter>[^\.]+?)\.(?P<service>[^\.]+?)\.(?P<host>[^\.]+?)\.(?P<measurement>[^\s]+?)\s%{NUMBER:value:float}\s*%{INT:time} - format.ToJSON: {}
func (*Grok) ApplyFormatter ¶
ApplyFormatter update message payload
func (*Grok) Configure ¶
func (format *Grok) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Hostname ¶
type Hostname struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Hostname formatter
This formatter prefixes the message or metadata with the hostname of the machine gollum is running on.
Parameters ¶
- Separator: Defines the separator string placed between hostname and data. By default this parameter is set to ":".
Examples ¶
This example inserts the hostname into an existing JSON payload.
exampleProducer: Type: producer.Console Streams: "*" Modulators: - format.Trim: LeftSeparator: "{" RightSeparator: "}" - format.Hostname Separator: "," - format.Envelope: Prefix: "{\"host\":" Postfix: "}"
func (*Hostname) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter update message payload
func (*Hostname) Configure ¶
func (format *Hostname) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Identifier ¶
type Identifier struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Identifier formatter
This formatter generates a (mostly) unique 64 bit identifier number from the message payload, timestamp and/or sequence number. The number is be converted to a human readable form.
Parameters ¶
- Generator: Defines which algorithm to use when generating the identifier. This my be one of the following values. By default this parameter is set to "time"
hash: The message payload will be hashed using fnv1a and returned as hex.
time: The id will be formatted YYMMDDHHmmSSxxxxxxx where x denotes the current sequence number modulo 10000000. I.e. 10.000.000 messages per second are possible before a collision occurs.
seq: The sequence number will be used.
seqhex: The hex encoded sequence number will be used.
Examples ¶
This example will generate a payload checksum and store it to a metadata field called "checksum".
ExampleConsumer: Type: consumer.Console Streams: console Modulators: - formatter.Identifier Generator: hash Target: checksum
func (*Identifier) ApplyFormatter ¶ added in v0.5.0
func (format *Identifier) ApplyFormatter(msg *core.Message) error
ApplyFormatter update message payload
func (*Identifier) Configure ¶
func (format *Identifier) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type JSON ¶
type JSON struct {
core.SimpleFormatter `gollumdoc:"embed_type"`
}
JSON formatter
This formatter parses json data into metadata.
Examples ¶
This example parses the payload as JSON and stores it below the key "data".
exampleConsumer: Type: consumer.Console Streams: stdin Modulators: - format.JSON Target: data
func (*JSON) ApplyFormatter ¶
ApplyFormatter update message payload
func (*JSON) Configure ¶
func (format *JSON) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Move ¶
type Move struct {
core.SimpleFormatter `gollumdoc:"embed_type"`
}
Move formatter
This formatter moves data from one location to another. When targeting a metadata key, the target key will be created or overwritten. When the source is the payload, it will be cleared.
Examples ¶
This example moves the payload produced by consumer.Console to the metadata key data.
exampleConsumer: Type: consumer.Console Streams: stdin Modulators: - format.Move Target: data
func (*Move) ApplyFormatter ¶
ApplyFormatter update message payload
func (*Move) Configure ¶
func (format *Move) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type RegExp ¶ added in v0.5.0
type RegExp struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
RegExp formatter
This formatter parses a message using a regular expression, performs string (template) replacement and returns the result.
Parameters ¶
- Posix: Set to true to compile the regular expression using posix semantics. By default this parameter is set to true.
- Expression: Defines the regular expression used for parsing. For details on the regexp syntax see https://golang.org/pkg/regexp/syntax. By default this parameter is set to "(.*)"
- Template: Defines the result string. Regexp matching groups can be referred to using "${n}", with n being the group's index. For other possible reference semantics, see https://golang.org/pkg/regexp/#Regexp.Expand. By default this parameter is set to "${1}"
Examples ¶
This example extracts time and host from an imaginary log message format.
exampleConsumer: Type: consumer.Console Streams: stding Modulators: - format.RegExp: Expression: "^(\\d+) (\\w+): " Template: "time: ${1}, host: ${2}"
func (*RegExp) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter update message payload
func (*RegExp) Configure ¶ added in v0.5.0
func (format *RegExp) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Replace ¶
type Replace struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Replace formatter
This formatter replaces all occurrences in a string with another.
Parameters ¶
- Search: Defines the string to search for. When left empty, the target will be completely replaced by ReplaceWith. By default this is set to "".
- ReplaceWith: Defines the string to replace all occurences of "search" with. By default this is set to "".
Examples
ExampleConsumer: Type: consumer.Console Streams: console Modulators: - format.Replace: Search: "foo" ReplaceWith: "bar"
func (*Replace) ApplyFormatter ¶
ApplyFormatter update message payload
func (*Replace) Configure ¶
func (format *Replace) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Runlength ¶
type Runlength struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Runlength formatter plugin
Runlength is a formatter that prepends the length of the message, followed by a ":". The actual message is formatted by a nested formatter.
Parameters ¶
- Separator: This value is used as separator. By default this parameter is set to ":".
- StoreRunlengthOnly: If this value is set to "true" only the runlength will stored. This option is useful to e.g. create metadata fields only containing the length of the payload. When set to "true" the Separator parameter will be ignored. By default this parameter is set to false.
Examples ¶
This example will store the length of the payload in a separate metadata field.
exampleConsumer: Type: consumer.Console Streams: "*" Modulators: - format.MetadataCopy: CopyToKeys: ["length"] - format.Runlength: Target: length StoreRunlengthOnly: true
func (*Runlength) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter update message payload
func (*Runlength) Configure ¶
func (format *Runlength) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Sequence ¶
type Sequence struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Sequence formatter
This formatter prefixes data with a sequence number managed by the formatter. All messages passing through an instance of the formatter will get a unique number. The number is not persisted, i.e. it restarts at 0 after each restart of gollum.
Parameters ¶
- Separator: Defines the separator string placed between number and data. By default this parameter is set to ":".
Examples ¶
This example will insert the sequence number into an existing JSON payload.
exampleProducer: Type: producer.Console Streams: "*" Modulators: - format.Trim: LeftSeparator: "{" RightSeparator: "}" - format.Sequence Separator: "," - format.Envelope: Prefix: "{\"seq\":" Postfix: "}"
func (*Sequence) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter update message payload
func (*Sequence) Configure ¶
func (format *Sequence) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Split ¶
type Split struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Split formatter
This formatter splits data into an array by using the given delimiter and stores it at the metadata key denoted by target. Targeting the payload (by not given a target or passing an empty string) will result in an error.
Parameters ¶
- Delimiter: Defines the delimiter to use when splitting the data. By default this parameter is set to ","
Examples
ExampleConsumer: Type: consumer.Console Streams: console Modulators: - format.Split: Target: values Delimiter: ":"
func (*Split) ApplyFormatter ¶
ApplyFormatter update message payload
func (*Split) Configure ¶
func (format *Split) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type SplitPick ¶ added in v0.4.5
type SplitPick struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
SplitPick formatter
This formatter splits data into an array by using the given delimiter and extracts the given index from that array. The value of that index will be written back.
Parameters ¶
- Delimiter: Defines the delimiter to use when splitting the data. By default this parameter is set to ","
- Index: Defines the index to pick. By default this parameter is set to 0.
Examples
ExampleConsumer: Type: consumer.Console Streams: console Modulators: - format.SplitPick: Index: 2 Delimiter: ","
func (*SplitPick) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter update message payload
func (*SplitPick) Configure ¶ added in v0.4.5
func (format *SplitPick) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type SplitToFields ¶
type SplitToFields struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
SplitToFields formatter
This formatter splits data into an array by using the given delimiter and stores it at the metadata key denoted by Fields.
Parameters ¶
- Delimiter: Defines the delimiter to use when splitting the data. By default this parameter is set to ","
- Fields: Defines a index-to-key mapping for storing the resulting list into Metadata. If there are less entries in the resulting array than fields, the remaining fields will not be set. If there are more entries, the additional indexes will not be handled. By default this parameter is set to an empty list.
Examples ¶
This example will split the payload by ":" and writes up to three elements as keys "first", "second" and "third" as fields below the field "values".
ExampleProducer: Type: proucer.Console Streams: console Modulators: - format.SplitToFields: Target: values Delimiter: ":" Fields: [first,second,third]
func (*SplitToFields) ApplyFormatter ¶
func (format *SplitToFields) ApplyFormatter(msg *core.Message) error
ApplyFormatter update message payload
func (*SplitToFields) Configure ¶
func (format *SplitToFields) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type StreamName ¶ added in v0.4.0
type StreamName struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
StreamName formatter
This formatter prefixes data with the name of the current or previous stream.
Parameters ¶
- UsePrevious: Set to true to use the name of the previous stream. By default this parameter is set to false.
- Separator: Defines the separator string used between stream name and data. By default this parameter is set to ":".
Examples ¶
This example prefixes the message with the most recent routing history.
exampleProducer: Type: producer.Console Streams: "*" Modulators: - format.StreamName: Separator: ", " UsePrevious: true - format.StreamName: Separator: ": "
func (*StreamName) ApplyFormatter ¶ added in v0.5.0
func (format *StreamName) ApplyFormatter(msg *core.Message) error
ApplyFormatter update message payload
func (*StreamName) Configure ¶ added in v0.4.0
func (format *StreamName) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type StreamRevert ¶ added in v0.4.0
type StreamRevert struct {
core.SimpleFormatter `gollumdoc:"embed_type"`
}
StreamRevert formatter
This formatter gets the previously used stream from a message and sets it as the new target stream.
Examples
ExampleConsumer: Type: consumer.Console Streams: console Modulators: - format.StreamRevert
func (*StreamRevert) ApplyFormatter ¶ added in v0.5.0
func (format *StreamRevert) ApplyFormatter(msg *core.Message) error
ApplyFormatter update message payload
func (*StreamRevert) Configure ¶ added in v0.4.0
func (format *StreamRevert) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type StreamRoute ¶ added in v0.4.0
type StreamRoute struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
StreamRoute formatter plugin
StreamRoute is a formatter that modifies a message's stream by reading a prefix from the message's data (and discarding it). The prefix is defined as everything before a given delimiter in the message. If no delimiter is found or the prefix is empty the message stream is not changed.
Parameters ¶
- Delimiter: This value defines the delimiter to search when extracting the stream name. By default this parameter is set to ":".
- StreamModulator: A list of further modulators to format and filter the extracted stream name. By default this parameter is "empty".
Examples ¶
This example sets the stream name for messages like `<error>:a message string` to `error` and `a message string` as payload:
exampleConsumer: Type: consumer.Console Streams: "*" Modulators: - format.StreamRoute: Delimiter: ":" StreamModulator: - format.Trim: LeftSeparator: < RightSeparator: >
func (*StreamRoute) ApplyFormatter ¶ added in v0.5.0
func (format *StreamRoute) ApplyFormatter(msg *core.Message) error
ApplyFormatter update message payload
func (*StreamRoute) Configure ¶ added in v0.4.0
func (format *StreamRoute) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Template ¶
type Template struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Template formatter
This formatter allows to apply go templating to a message based on the currently set metadata. The template language is described in the go documentation: https://golang.org/pkg/text/template/#hdr-Actions
Parameters ¶
- Template: Defines the go template to apply. By default this parameter is set to "".
Examples ¶
This example writes the fields "Name" and "Surname" from metadata as the new payload.
exampleProducer: Type: proucer.Console Streams: "*" Modulators: - format.Template: Template: "{{.Name}} {{.Surname}}"
func (*Template) ApplyFormatter ¶
ApplyFormatter update message payload
func (*Template) Configure ¶
func (format *Template) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Timestamp ¶
type Timestamp struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Timestamp formatter plugin
Timestamp is a formatter that allows prefixing messages with a timestamp (time of arrival at gollum). The timestamp format is freely configurable and can e.g. contain a delimiter sequence at the end.
Parameters ¶
- Timestamp: This value defines a Go time format string that is used to f ormat the timestamp. By default this parameter is set to "2006-01-02 15:04:05 MST | ".
Examples ¶
This example will set a time string to the meta data field `time`:
exampleConsumer: Type: consumer.Console Streams: "*" Modulators: - format.Timestamp: Timestamp: "2006-01-02T15:04:05.000 MST" Target: time
func (*Timestamp) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter update message payload
func (*Timestamp) Configure ¶
func (format *Timestamp) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type ToCSV ¶
type ToCSV struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
ToCSV formatter plugin
ToCSV converts a set of metadata keys to CSV and applies it to Target.
Parameters ¶
- Keys: List of strings specifying the keys to write as CSV. Note that these keys can be paths. By default this parameter is set to an empty list.
- Separator: The delimited string to insert between each value in the generated string. By default this parameter is set to ",".
- KeepLastSeparator: When set to true, the last separator will not be removed. By default this parameter is set to false.
Examples ¶
This example get sthe `foo` and `bar` keys from the metdata of a message and set this as the new payload.
exampleProducer: Type: producer.Console Streams: "*" Modulators: - format.ToCSV: Separator: ';' Keys: - 'foo' - 'bar'
func (*ToCSV) ApplyFormatter ¶
ApplyFormatter update message payload
func (*ToCSV) Configure ¶
func (format *ToCSV) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type ToJSON ¶
type ToJSON struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
ToJSON formatter
This formatter converts metadata to JSON and stores it where applied.
Parameters ¶
- Root: The metadata key to transform to json. When left empty, all metadata is assumed. By default this is set to ”.
- Ignore: A list of keys or paths to exclude from marshalling. please note that this is currently a quite expensive operation as all metadata below root is cloned during the process. By default this is set to an empty list.
Examples ¶
This example transforms all metadata below the "foo" key to JSON and stores the result as the new payload.
exampleProducer: Type: consumer.Producer Streams: stdin Modulators: - format.ToJSON Root: "foo"
func (*ToJSON) ApplyFormatter ¶
ApplyFormatter update message payload
func (*ToJSON) Configure ¶
func (format *ToJSON) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type Trim ¶ added in v0.5.0
type Trim struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
Trim formatter plugin
Trim removes a set of characters from the beginning and end of a metadata value or the payload.
Parameters ¶
- Characters: This value defines which characters should be removed from both ends of the data. The data to operate on is expected to be a string. By default this is set to " \t\r\n\v\f".
Examples ¶
This example will trim spaces from the message payload:
exampleConsumer: Type: consumer.Console Streams: "*" Modulators: - format.Trim: {}
func (*Trim) ApplyFormatter ¶ added in v0.5.0
ApplyFormatter update message payload
func (*Trim) Configure ¶ added in v0.5.0
func (format *Trim) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
type TrimToBounds ¶
type TrimToBounds struct { core.SimpleFormatter `gollumdoc:"embed_type"` // contains filtered or unexported fields }
TrimToBounds formatter
This formatter searches for separator strings and removes all data left or right of this separator.
Parameters ¶
- LeftBounds: The string to search for. Searching starts from the left side of the data. If an empty string is given this parameter is ignored. By default this parameter is set to "".
- RightBounds: The string to search for. Searching starts from the right side of the data. If an empty string is given this parameter is ignored. By default this parameter is set to "".
- LeftOffset: Defines the search start index when using LeftBounds. By default this parameter is set to 0.
- RightOffset: Defines the search start index when using RightBounds. Counting starts from the right side of the message. By default this parameter is set to 0.
Examples ¶
This example will reduce data like "foo[bar[foo]bar]foo" to "bar[foo]bar".
exampleConsumer: Type: consumer.Console Streams: "*" Modulators: - format.TrimToBounds: LeftBounds: "[" RightBounds: "]"
func (*TrimToBounds) ApplyFormatter ¶
func (format *TrimToBounds) ApplyFormatter(msg *core.Message) error
ApplyFormatter update message payload
func (*TrimToBounds) Configure ¶
func (format *TrimToBounds) Configure(conf core.PluginConfigReader)
Configure initializes this formatter with values from a plugin config.
Source Files ¶
- agent.go
- aggregate.go
- base64decode.go
- base64encode.go
- converttime.go
- copy.go
- delete.go
- double.go
- envelope.go
- flatten.go
- geoip.go
- grok.go
- hostname.go
- identifier.go
- json.go
- move.go
- regexp.go
- replace.go
- runlength.go
- sequence.go
- split.go
- splitpick.go
- splittofields.go
- streamname.go
- streamrevert.go
- streamroute.go
- template.go
- timestamp.go
- tocsv.go
- tojson.go
- trim.go
- trimtobounds.go