Send Logstash to RabbitMQ in plain text format [no JSON]

时间:2015-07-31 20:35:00

标签: rabbitmq logstash

I am trying to send an event from logstash to rabbitmq. It works but, the event is getting "jsoned" by default. For example if my message is ABC, RabbitMQ gets the payload as,

{"message":"abc"}

I just want the payload to be simply "abc". How can I do that ?

my logstash config is as below:

output{
    stdout{
        codec => rubydebug
    }
    rabbitmq {
        codec         => json {charset =>"UTF-8"}
        host          => "192.100.12.23"
        password      => "guest"
        port          => 5672
        user          => "guest"
        vhost         => "/"
        exchange      => "myxchange"
        key           => "mykey"
        exchange_type => "direct"
        durable       => true
        persistent    => true
    }

}

I tried changing

codec         => json {charset =>"UTF-8"}

to

codec         => plain {charset =>"UTF-8"}

which gives me following error:

Error encoding event {:exception=>#<NoMethodError: undefined method `to_iso8601' for nil:NilClass>

1 个答案:

答案 0 :(得分:0)

您应该使用LogStash过滤器,文档为here