This does look correct, yes, although it's a bit more idiomatic in Lua to use
`if not severity` instead of `if severity == nil`. That's not going to cause
your problem, though.
I just tested this by expanding your code slightly:
https://rmiller.pastebin.mozilla.org/8826150
I used this config: https://rmiller.pastebin.mozilla.org/8826149
That's parsing nginx log files, extracting severity (along w/ lots of other data), using
the filter to keep a running total of severity values (absurd, but an effective sanity
check), and writing that ongoing total out to stdout. It's working as expected, and I'm
not seeing any of the "severity can't be nil" errors.
My guess is that you think your messages have a severity set, but they don't.
How are your messages being generated? Can you try using a LogOutput and
RstEncoder to catch the same messages and verify that severity is in fact set?
Thanks,
-r
On 03/17/2015 10:35 AM, bruno binet wrote:
In a lua sandbox filter, I'd like to get the value of the "Severity"
message variable, but in the "process_message" function if I do:
local severity = read_message("Severity")
if severity == nil then
return -1, "severity can't be nil"
end
when a message is processed by the sandbox, it always returns "severity
can't be nil" whereas the message Severity was set to 5.
Is "read_message" the right function to use to read the message Severity?
Thanks.
Bruno
_______________________________________________
Heka mailing list
[email protected]
https://mail.mozilla.org/listinfo/heka
_______________________________________________
Heka mailing list
[email protected]
https://mail.mozilla.org/listinfo/heka