Skip to content

Instantly share code, notes, and snippets.

@JeanMertz
Last active February 17, 2021 14:20
Show Gist options
  • Save JeanMertz/e02e949d215db80f9b87e7c075806081 to your computer and use it in GitHub Desktop.
Save JeanMertz/e02e949d215db80f9b87e7c075806081 to your computer and use it in GitHub Desktop.
./target/debug/vector -q --config test.toml
{"bar":2}
{"foo":1}
{"baz":3}
{"foo":1}
{"bar":2}
{"baz":3}
{"bar":2}
{"foo":1}
{"baz":3}
{"bar":2}
{"foo":1}
{"baz":3}
{"bar":2}
{"foo":1}
{"baz":3}
[sources.in]
type = "generator"
format = "shuffle"
interval = 1
lines = ['[{"foo": 1}, {"bar": 2}, {"baz": 3}]']
[sources.tail_in]
type = "vector"
address = "127.0.0.1:9000"
[transforms.parse]
type = "remap"
inputs = ["in", "tail_in"]
source = '.message = parse_json!(string!(.message))'
[transforms.split]
type = "route"
inputs = ["parse"]
route.0 = '.message[0] != null'
route.1 = '.message[1] != null'
route.tail = 'length(array!(.message)) > 2'
[transforms.event1]
type = "remap"
inputs = ["split.0"]
source = '. = .message[0]'
[transforms.event2]
type = "remap"
inputs = ["split.1"]
source = '. = .message[1]'
[transforms.tail_events]
type = "remap"
inputs = ["split.tail"]
source = '.message = encode_json(slice!(array!(.message), 2))'
[sinks.tail_out]
type = "vector"
inputs = ["tail_events"]
address = "localhost:9000"
[sinks.out]
type = "console"
inputs = ["event1", "event2"]
encoding.codec = "json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment