I came across this problem and thought you'd be able to help me figure it out. I created a CSV filter to parse my httpd access log file and it's working fine. We have a field "HttpStatus" in our csv filter and this field is sent to ELK as a string. We're trying to create a copy of this field using addfield, keeping the original one unchanged and convert this new field to integer. I saw in the logstash documentation that the data type we get out from a addfield operation is hash, and that the convert operation cant't perform anything when the datatype is hash. How can we acomplish this?
Where did you read that the output of add_field is a hash? It's a normal string. Your input for that operation is a hash because you have to give it a key and a value for every field that has to be added.
I think your actual problem is more likely the fact that you try to add and convert the field in the same filter. But the execution order of mutate is not the order of your parameters. In fact there is no guaranteed order, so you have to split up operations that rely on each other. The correct syntax would be
But to go even further: add_field one of the default options for every kind of filter and is only executed if the filter has been successful, so you might want to use copy instead.
Yeah, fair enough. The code does have to have an order. I just meant that I wouldn't rely on it to stay the same as long as the official documentation doesn't specify this But in principle you are right.
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.