Loading...

Convert multiple fields with mutate plugin for logstash

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

The mutate plugin allows to convert fields into other data types. The existing example does not illustrate how to convert multiple fields.

Find below an example, how to convert multiple fields from string into number formats.

filter {
    csv {
        source => "data"
        columns => ['OpenFileDescriptorCount', 'MaxFileDescriptorCount', 'CommittedVirtualMemorySize', 'TotalSwapSpaceSize', 'FreeSwapSpaceSize', 'ProcessCpuTime', 'FreePhysicalMemorySize', 'TotalPhysicalMemorySize', 'SystemCpuLoad', 'ProcessCpuLoad', 'AvailableProcessors', 'Arch', 'SystemLoadAverage', 'Version', 'Name', 'ObjectName']
        separator => ";"
    }
    mutate {
        convert => {
            "OpenFileDescriptorCount" => "integer"
            "MaxFileDescriptorCount" => "integer"
            "CommittedVirtualMemorySize" => "integer"
            "TotalSwapSpaceSize" => "integer"
            "FreeSwapSpaceSize" => "integer"
            "ProcessCpuTime" => "integer"
            "FreePhysicalMemorySize" => "integer"
            "TotalPhysicalMemorySize" => "integer"
            "SystemCpuLoad" => "float"
            "ProcessCpuLoad" => "float"
            "AvailableProcessors" => "integer"
            "SystemLoadAverage" => "float"
        }
    }
}

See also Discuss Elastic