SuperCoder
SuperCoder

Reputation: 849

Logstash - Converting String to an Integer

In my Logstash I have below configuration:

filter {
   mutate {
        add_field => {
            "doclength" => "%{size}"
        }
        convert => {"doclength" => "integer"}
        remove_field => ["size"]
    }
}

I intend to store the field "doclength" into ElasticSearch as an integer. But somehow in ES, it shows mapping as "string" only.

Not sure what I am missing in here, the expected behavior is not matching up with the actual one.

Upvotes: 2

Views: 6736

Answers (1)

Mrunal Pagnis
Mrunal Pagnis

Reputation: 809

Try this one, it worked on my machine.

filter {
   mutate {
        convert => {"size" => "integer"}
        rename => { "size" => "doclength" }
    }
}

Upvotes: 5

Related Questions