Skip to content

Instantly share code, notes, and snippets.

@jszwedko
Last active August 7, 2020 19:28
Show Gist options
  • Save jszwedko/e0f55c85445b428aa067315c64ab13b4 to your computer and use it in GitHub Desktop.
Save jszwedko/e0f55c85445b428aa067315c64ab13b4 to your computer and use it in GitHub Desktop.
➜ vector git:(master) echo 'hello' | cargo run -- --config /tmp/tmp.toml
Finished dev [unoptimized + debuginfo] target(s) in 0.49s
Running `target/debug/vector --config /tmp/tmp.toml`
Aug 07 15:18:46.732 INFO vector: Log level "info" is enabled.
Aug 07 15:18:46.738 INFO vector: Loading configs. path=["/tmp/tmp.toml"]
Aug 07 15:18:46.757 INFO vector: Vector is starting. version="0.11.0" git_version="v0.9.0-494-g21354bf" released="Fri, 07 Aug 2020 18:51:18 +0000" arch="x86_64"
Aug 07 15:18:46.759 INFO vector::sources::stdin: Capturing STDIN.
Aug 07 15:18:46.760 INFO vector::topology: Running healthchecks.
Aug 07 15:18:46.760 INFO vector::topology: Starting source "in"
Aug 07 15:18:46.760 INFO vector::topology::builder: Healthcheck: Passed.
Aug 07 15:18:46.761 INFO vector::topology: Starting transform "lua"
Aug 07 15:18:46.761 INFO vector::topology: Starting sink "out"
Aug 07 15:18:46.779 INFO vector::shutdown: All sources have finished.
Aug 07 15:18:46.779 INFO vector: Shutting down.
Aug 07 15:18:46.779 INFO source{name=in type=stdin}: vector::sources::stdin: finished sending
{"records":[{"value":{"host":"a-8cktst39ij0a","message":"hello","source_type":"stdin","timestamp":"2020-08-07T19:18:46.778527456Z"}}]}
Aug 07 15:18:46.782 INFO vector::topology: Shutting down... Waiting on: . 59 seconds left
[sources.in]
type = "stdin"
[transforms.lua]
# General
type = "lua" # required
inputs = ["in"] # required
version = "2" # required
# Hooks
hooks.process = """
function (event, emit)
record = {}
record.value = event.log
records = {}
table.insert(records, record)
event.log = {}
event.log.records = records
-- Very important! Emit the processed event.
emit(event)
end
"""
[sinks.out]
type = "console" # required
inputs = ["lua"] # required
encoding.codec = "json"
@jszwedko
Copy link
Author

jszwedko commented Aug 7, 2020

If using HTTP sink:

[sinks.out]
  type = "http" # required
  inputs = ["lua"] # required
  uri = "http://localhost:8080/" # required
  encoding.codec = "ndjson" # required

  batch.max_events = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment