Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect data type conversion #73

Open
masech opened this issue Aug 11, 2020 · 0 comments
Open

Incorrect data type conversion #73

masech opened this issue Aug 11, 2020 · 0 comments

Comments

@masech
Copy link

masech commented Aug 11, 2020

  • Version: 7.8.1 and earlier
  • Operating System: CentOS 7, Ubuntu 18.04
  • Config File:
input {
    generator {
        lines => [
            "1.0.0.0",
            "0.0.0.0"
        ]
        count => 1
    }
}

filter {
    dissect {
        mapping => {
            "message" => "%{octet_1}.%{octet_2}.%{octet_3}.%{octet_4}"
        }
        convert_datatype => {
            "octet_1" => "int"
            "octet_2" => "int"
            "octet_3" => "int"
            "octet_4" => "int"
        }
    }

    if ([octet_1] != 0) {
        #add field 'TRUE' if 'octet_1' is not zero
        mutate {
            add_field => {
                "TRUE" => "Get True"
            }
        }

    } else {
        #add field 'FALSE' if 'octet_1' is zero
        mutate {
            add_field => {
                "FALSE" => "Get False"
            }
        }
    }
}

output {
    stdout {
        codec => rubydebug
    }
}

  • Expected output:
{
          "TRUE" => "Get True",
       "octet_1" => 1,
       "octet_3" => 0,
       "octet_2" => 0,
       "octet_4" => 0,
       "message" => "1.0.0.0"
}
{
          "FALSE" => "Get False",
       "octet_1" => 0,
       "octet_3" => 0,
       "octet_2" => 0,
       "octet_4" => 0,
       "message" => "0.0.0.0"
}

  • Actual output:
{
          "TRUE" => "Get True",
       "octet_1" => 1,
       "octet_3" => 0,
       "octet_2" => 0,
       "octet_4" => 0,
       "message" => "1.0.0.0"
}
{
          ""TRUE" => "Get True",
       "octet_1" => 0,
       "octet_3" => 0,
       "octet_2" => 0,
       "octet_4" => 0,
       "message" => "0.0.0.0"
}

  • Steps to Reproduce: the pipeline.java_execution setting in the /etc/logstash/logstash.yml file must be enabled (value is true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant