Hi,
I'm trying to write a tag or a field in @metadata
in an output plugin but can't match that value in a if statement.
Here's the output block:
output {
something {
...setting the tag/field inside this plugin...
}
if "_outputfailed" in [tags] {
statsd {
increment => [ "fail" ]
}
} else {
statsd {
increment => [ "success" ]
}
}
}
I can clearly see the tag if I send the event to stdout, same thing with the @metadata
field, it's there and it's an integer, but I can't match against it. I've also tried to use the value in the statsd increment call like: fail_%{[@metadata][output_status]}
, that's always set to the expected output status and renders fail_200
. I've tried matching both strings and integers, exact match and in list matches, nothing works.
Statements I've tested, all failing, value of the @metadata
field is 200
:
if "_outputfailed" in [tags]
if [tags] in ["_outputfailed"]
if [@metadata][output_status] == 200
if [@metadata][output_status] == "200"
if [@metadata][output_status] in [200, 201]
if [@metadata][output_status] in ["200", "201"]
So my question is, can I set a field or tag in an output plugin and match against it? Or how can I see if my output filter got an error and handle it?
-- William