-
|
vector version: timberio/vector:0.42.0-debian [sources.demo_source]
type = "demo_logs"
format = "apache_common"
lines = [ "line1" ]
[transforms.transform_nginx_log]
type = "remap"
inputs = [ "demo_source" ]
drop_on_error = true
drop_on_abort = true
reroute_dropped = true
source = """
log = parse_apache_log!(.message,format: "common")
if to_int(log.status) > 200 {
abort
}
. = log
.mark = "transform_nginx_log"
"""
[sinks.transform_nginx_log_sink]
type = "console"
inputs = [ "transform_nginx_log" ]
encoding.codec = "json"
[transforms.transform_nginx_log_dropped]
type = "remap"
inputs = [ "transform_nginx_log.dropped" ]
source = """
.mark = "dropped"
"""
[sinks.dropped_msg_sink]
type = "console"
inputs = [ "transform_nginx_log_dropped" ]
encoding.codec = "json"But when writing the vrl for transform_nginx_log, I'm a bit confused. but I got error Ok,I think it's vrl thinks the type of log.status is uncertain, so I'm going to use to_int to convert the type of log.status. So I followed the documentation and wrote a second version. I got a new error. I'm not sure if I'm missing any content. The documentation says that Is there a problem I'm overlooking? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Basically the compiler has different type information for each example you mentioned. This example demonstrates when See that and |
Beta Was this translation helpful? Give feedback.
-
|
Thank you. The exception thrown there by the greater-than is log.status, which may be null. I incorrectly assumed that any type was the cause. |
Beta Was this translation helpful? Give feedback.
Basically the compiler has different type information for each example you mentioned. This example demonstrates when
!is needed and when it is not based on the type info: exampleSee that
log.statusis known to be:and
to_intworks on both the above types.