Hi, I have a JSON coming from RabbitMQ structured as shown below:
{
"MessageItemsCount": 8106,
"Message": "[{\"Id\":\"Foo_123_456\",\"NetworkShopId\":\"333\",\"Name\":\"Some product\",\"Description\":\"Blah blah\",\"Categories\":null,\"Brand\":null,\"PhotoUrl\":\"Some url\",\"ProductUrl\":\"Some url\",\"Price\":259.0,\"RetailPrice\":259.0,\"CurrencyCode\":\"USD\"}]",
"NetworkName": "Foo"
}
Message
field contain JSON array of multiple products up to 10000. Fields MessageItemsCount
and NetworkName
are irrelevant to me. All I want is to parse the inner JSON kept in Message
field and then split it to single messages so I can send them to elasticsearch as separate documents. If the particular product contain ProductId
field then delete action is called instead of the default create or update.
What I've got so far:
input {
rabbitmq {
host => "localhost"
queue => "create_or_update_products"
port => 15672
heartbeat => 30
durable => false
user => "guest"
password => "guest"
}
rabbitmq {
host => "localhost"
queue => "delete_products"
port => 15672
heartbeat => 30
durable => false
user => "guest"
password => "guest"
}
}
filter {
json {
source => "Message"
target => "Message"
}
split {
field => "Message"
target => "Message"
}
}
output {
if([ProductId]){
elasticsearch {
action => delete
hosts => "localhost:9200"
index => "products"
document_id => "%{[ProductId]}"
}
}
else{
elasticsearch {
hosts => "localhost:9200"
index => "products"
document_id => "%{[Id]}"
}
}
}
Unfortunately, it doesn't work. Thanks for help!