Skip to content

Event type in lua is userdata, not table #1297

@mikhno-s

Description

@mikhno-s

Hi!

Docs says that event has lua type table, I get userdata, hence, I cannot use pairs function.

My configuration:

OS: OS X 10.14.6
Vector ver.:vector 0.6.0-nightly (the same problem on v0.4.0 and 0.5.0, probably)

config.toml:

data_dir = "${PWD}/data"

[sources.in_err_logs]
    type = "file"
    include = ["./*.log"]
    glob_minimum_cooldown = 1000
    ignore_older = 86400
    max_read_bytes = 4096

    
[sources.in_err_logs.fingerprinting]
    strategy = "checksum"
    fingerprint_bytes = 16
    ignored_header_bytes = 0

[transforms.test]
    type = "lua"
    inputs = ["in_err_logs"]
    source = """
       print(type(event))
    """

[sinks.print_to_console]
  type = "console"
  inputs = ["test"]
  encoding = "json"

error.log:

{"MESSAGE":{"text":"error"}}

output:

$ vector --config config.toml
Dec 02 16:55:16.012  INFO vector: Log level "info" is enabled.
Dec 02 16:55:16.013  INFO vector: Loading config. path="config.toml"
Dec 02 16:55:16.031  INFO vector: Vector is starting. version="0.6.0" git_version="v0.5.0-198-ga6668b0" released="Mon, 02 Dec 2019 11:16:59 +0000" arch="x86_64"
Dec 02 16:55:16.038  INFO vector::topology: Running healthchecks.
Dec 02 16:55:16.038  INFO vector::topology: Starting source "in_err_logs"
Dec 02 16:55:16.039  INFO vector::topology: Starting transform "test"
Dec 02 16:55:16.039  INFO vector::topology::builder: Healthcheck: Passed.
Dec 02 16:55:16.039  INFO vector::topology: Starting sink "print_to_console"
Dec 02 16:55:16.040  INFO source{name=in_err_logs type=file}: vector::sources::file: Starting file server. include=["./*.log"] exclude=[]
Dec 02 16:55:16.042  INFO source{name=in_err_logs type=file}:file_server: file_source::file_server: Found file to watch. path="error.log" file_position=0
userdata
{"timestamp":"2019-12-02T14:55:16.044518Z","file":"error.log","host":"my-mac.local","message":"{\"MESSAGE\":{\"text\":\"error\"}}"}

As you can see print(type(event)) - printed userdata, not a table as I expected due to docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    transform: luaAnything `lua` transform relatedtype: bugA code related bug.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions