Loading...

Convert multiple fields with mutate plugin for logstash

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