Generic Functions
Truncate
The Truncate function limits string fields to a specified length in bytes or characters.
Usage
- Operates On: Field values
- Supported Field Types: string
- Mode: Specific Field | Target Map | Matching
- Label: Optional
- Filter: Optional
Specific Fields Mode - Required Configuration
- Specific Fields: A comma separated list of fields to truncate
- Limit: The max length for the field
- Limit Type: Bytes | Characters
Target Map Mode - Required Configuration
- Target Map: The name of field to truncate children string fields. Must be of type map
- Limit: The max length for the field
- Limit Type: Bytes | Characters
Optional Configuration
- Excluded Fields: A comma separated list of field names to not apply truncation to.
Matching Mode - Required Configuration
- Target Map: The name of field to truncate children string fields. Must be of type map
- Limit: The max length for the field
- Limit Type: Bytes | Characters
- Matching Expression: The matching expression to select field names or values to trigger truncation. Supports wildcard matches or a regular expression. Regular expressions should be wrapped in
//
. - Expression Match On: Field Name | Field Value | Field Name or Value
Example - Specific Fields
Truncate the stack_trace
field to 128 bytes in order to strip the lower stack trace frames.
Configuration
- Mode: Specific Fields
- Specific Fields:
example.stack_trace
- Limit:
128
- Limit Type:
bytes
Before
{
"example" : {
"stack_trace": "goroutine 91 [IO wait]:\ninternal/poll.runtime_pollWait(0x7fa0acc67790, 0x72)\n/usr/local/go/src/runtime/netpoll.go:343 +0x85\ninternal/poll.(*pollDesc).wait(0xc000946000?, 0xc000b3a000?, 0x0)\n/usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x27\ninternal/poll.(*pollDesc).waitRead(...)\n/usr/local/go/src/internal/poll/fd_poll_runtime.go:89\ninternal/poll.(*FD).Read(0xc000946000, {0xc000b3a000, 0x8000, 0x8000})\n/usr/local/go/src/internal/poll/fd_unix.go:164 +0x27a\nnet.(*netFD).Read(0xc000946000, {0xc000b3a000?, 0x10?, 0xc000ab0e38?})\n/usr/local/go/src/net/fd_posix.go:55 +0x25"
}
}
After
{
"example" : {
"stack_trace": "goroutine 91 [IO wait]:\ninternal/poll.runtime_pollWait(0x7fa0acc67790, 0x72)\n/usr/local/go/src/runtime/netpoll.go:343 +0x85\ninte"
}
}
Example - Target Map
Trim all field values in log.errors
to a 10 character maximum length, except for the message
field.
Configuration
- Mode: Target Map
- Target Map:
log.errors
- Limit:
10
- Limit Type:
characters
- Excluded Fields:
message
Before
{
"log" : {
"errors": {
"stack": "(RuntimeError)\n\tfrom /home/mheffner/git/streamfold/banjo-store/.bundle/gems/ruby",
"location": "/home/mheffner/git/streamfold/banjo-store/.bundle/gems/ruby",
"message": "NameError: undefined local variable or method 'intro'"
}
}
}
After
{
"log" : {
"errors": {
"stack": "(RuntimeEr",
"location": "/home/mhef",
"message": "NameError: undefined local variable or method 'intro'"
}
}
}
Example - Matching
Truncate all fields matching error*
in the log
map to 10 characters.
Configuration
- Mode: Matching
- Target Map:
log
- Limit:
10
- Limit Type:
characters
- Matching Expression: Field Name:
error*
Before
{
"log" : {
"error": "Can not connect to MySQL",
"error.verbose": "(RuntimeError)\n\tfrom /home/mheffner/git/streamfold/banjo-store/: Can not connect to MySQL",
"msg": "Error connecting to database"
}
}
After
{
"log" : {
"error": "Can not co",
"error.verbose": "(RuntimeEr",
"msg": "Error connecting to database"
}
}