Simon Klibi
Simon Klibi

Reputation: 1

Logstash : convert string to array

I have csv file that has types column with array of integers in format:

id,date,state,types,x,y
14518263,2021-01-01 20:20:00,2,"18,19,63,72",14.46154,50.07164

Could someone help me with converting types column into array via filter in pipeline?

Upvotes: 0

Views: 902

Answers (2)

Ashutosh kumar
Ashutosh kumar

Reputation: 1

You need to use two filter for this, First, you need to split it into string array based on the splitter or seperator then you need to convert it to desired data type here integer

mutate {
        split => { "field1" => "," }
        split => { "field2" => "," }
    }enter code here
    mutate {
        convert => { "field1" => "integer" }
        convert => { "field2" => "integer" }

  

Upvotes: 0

Paulo
Paulo

Reputation: 10356

So I feel you need two steps for this.

You will be using 2 mutation filter to do so.

filter {
    mutate {
        split => { "<your field name>" => "," }
    }
    mutate {
        convert => { "<your field name>" => "integer" }
    }
}

For reference there was a discussion going on here

Upvotes: 1

Related Questions