Http output "Mapping" setting sends all properties as strings

Hello,

I'm on Logstash v7.17, using 'http output' plugin to send logs to third party API.

Per third party API spec and hard requirement, "zip" POST property must be a number, otherwise API rejects it.

When I use "mapping" setting (example below), every property, including "zip", which is hardcoded as an int, still gets sent as a string.

Is there any way to send it as a number (int or float)?

output {
    http {
        url => "url.com"
        http_method => "post"
        format => "json_batch"
        codec => "json"
      
        mapping => {
            "name" => "Test User"
            "address" => "1234 Some Street"
            "zip" => 50001
        }
    }
}

I don't think so. There is an open issue about this and another that I think says the same for booleans.

I suspect the problem will be something like this. logstash uses JrJackson but I haven't followed through the dependencies to be certain that that is the exact code in play.

You may be able to work around it using something like

codec => plain
content_type => "application/json"
message => '{ "name": "%{name}", "address": "%{address}", "zip": %{zip} }'
1 Like

Thank you for the suggestion and sending me in the right direction. Only needed to set format to message and now able to dictate the type using message option instead of mapping (as shown above). :folded_hands:

If message, then the body will be the result of formatting the event according to message