Documentation
¶
Overview ¶
Package transformer provides the means to mutate a container as part of a skogul.Handler, before it is passed on to a Sender.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Auto skogul.ModuleMap
Auto maps names to Transformers to allow auto configuration
Functions ¶
This section is empty.
Types ¶
type Case ¶ added in v0.3.0
type Case struct { When string `doc:"Used as a conditional statement on a field"` Is string `doc:"Used for the specific value (string) of the stated metadata field"` Transformers []*skogul.TransformerRef `doc:"The transformers to run when the defined conditional is true"` }
Case requires a field ("when") and a value ("is") to match for the set of transformers to run
type Data ¶
type Data struct { Set map[string]interface{} `doc:"Set data fields to specific values."` Require []string `doc:"Require the pressence of these data fields."` Flatten [][]string `doc:"Flatten nested structures down to the root level"` FlattenSeparator string `` /* 137-byte string literal not displayed */ Remove []string `doc:"Remove these data fields."` Ban []string `doc:"Fail if any of these data fields are present"` }
Data enforces a set of rules on data in all metrics, potentially changing the metric data.
type Metadata ¶
type Metadata struct { Set map[string]interface{} `doc:"Set metadata fields to specific values."` Require []string `doc:"Require the pressence of these fields."` ExtractFromData []string `doc:"Extract a set of fields from Data and add it to Metadata. Removes the original."` Remove []string `doc:"Remove these metadata fields."` Ban []string `doc:"Fail if any of these fields are present"` }
Metadata enforces a set of rules on metadata in all metrics, potentially changing the metric metadata.
type Replace ¶ added in v0.2.0
type Replace struct { Source string `doc:"Metadata key to read from."` Destination string `` /* 222-byte string literal not displayed */ Regex string `doc:"Regular expression to match."` Replacement string `doc:"Replacement text. Can also use $1, $2, etc to reference sub-matches. Defaults to empty string - remove matching items."` // contains filtered or unexported fields }
Replace executes a regular expression replacement of metric metadata.
type Split ¶
type Split struct { Field []string `doc:"Split into multiple metrics based on this field (each field denotes the path to a nested object element)."` Fail bool `` /* 140-byte string literal not displayed */ }
Split is the configuration for the split transformer
type Switch ¶ added in v0.3.0
type Switch struct {
Cases []Case `doc:"A list of switch cases "`
}
Switch is a wrapper for a list of cases
type Templater ¶
type Templater struct{}
Templater iterates over all Metrics in a Skogul Container and fills in any missing template variable from the Template in the Container, so noone else has to.
Skogul Templates are shallow:
{ "template": { "metadata": { "foo": "bar", "geo": { "country": "Norway" } } }, "metrics": [ { "timestamp": "...", "metadata": { "name": "john", "geo": { "city": "Oslo" } }, "data": ... }, { "timestamp": "...", "metadata": { "name": "fred", "foo": "BANANA" }, "data": ... } ] }
Will result in:
{ "metrics": [ { "timestamp": "...", "metadata": { "name": "john", "foo", "bar", "geo": { "city": "Oslo" } }, "data": ... }, { "timestamp": "...", "metadata": { "name": "fred", "foo": "BANANA", "geo": { "country": "Norway" } }, "data": ... } ] }
The template just checked if "geo" was present in metadata or not - it did not merge missing keys.
It is good practice to use a template for any common fields, particularly timestamps.
type Timestamp ¶ added in v0.4.0
type Timestamp struct { Source []string `doc:"The source field of the timestamp"` Format string `doc:"The format to use (default: RFC3339)"` Fail bool `doc:"Propagate errors back to the caller. Useful if the timestamp is required for the container."` // contains filtered or unexported fields }
Timestamp is the configuration for extracing a timestamp from inside the data