The output does not contain the fingerprint that your filter would add. That very much suggests that you are not running the configuration you think you are running. What are you setting path.config to? How are you starting logstash?
If you have a single file output in a configuration file and two copies of the message get written to it then it is very likely you have two configuration files that contain that output.
It is a very common misunderstanding that if you have multiple configuration files they are run independently, but that is not the case unless you are using pipelines.yml. If path.config matches multiple files they are concatenated, events are read from all of the inputs, run through all the filters, and written to all of the events. If two configuration files have the same file output the event will be written twice.
A common way of getting hit by this is to point path.config to a directory, such as /etc/logstash/conf.d/. It will then gather up all the files (e.g. myConfig.conf, myConfig.conf.bak) and combine them.
By the way, if you have two syslog inputs on the same port one of them should be logging an error saying "address already in use".
I think put variable to resolve this. So the Output is write just when the fingerprint is validated..... But I don´t know how to put variable ... I tried ...
Check => TRUE
add_field => { "CHECK" => "TRUE"}
Do you have any suggestion ?
filter{
fingerprint {
source => "message"
target => "[@metadata][fingerprint]"
method => "SHA256"
}
ruby {
init => '@prints = []; @prints[9] = nil' # Sets 10 entries to nil
code => '
print = event.get("[@metadata][fingerprint]")
if @prints.include? print
event.cancel
add_field => { "CHECK" => "TRUE"}
else
@prints.shift # Drop first entry
@prints.push print # Append at end
add_field => {"CHECK" => "FALSE"}
end
'
}
}
output {
if [CHECK] == "FALSE" {
file {
path => "/var/log/logstash/firewall_test.log"
codec => line { format => "%{message}"}
}
}
The array needs to be big enough that the duplicate message arrives before the print of the first version gets shifted out of the array. So you will very likely have to increase the size of the array.
I do not know how the cost of .shift and .push change with the size of the array.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.