Hi,
I am wanting to change an Array to a String to make it easier for me to store in my Elasticsearch, but I am having trouble finding the way of doing so. There are some special cases in my data where my field "value" will have an Array instead of a String, but I seem to not be able to add the three double quotes infront and behind my square brackets where I need them.
The following shows how my data looks like:
{
"Data": [{
"key": "keyName",
"value": "valueName"
},
{
"key": "keyName",
"value": "valueName"
},
{
"key": "keyName",
"value": [{
"type": "FailedName",
"message": "FailedMessage",
"path": "FailedPath"
}]
}
]
}
and here is how I want it to be inserted in ES:
{
"Data": [{
"key": "keyName",
"value": "valueName"
},
{
"key": "keyName",
"value": "valueName"
},
{
"key": "keyName",
"value": """[{
"type": "FailedName",
"message": "FailedMessage",
"path": "FailedPath"
}]"""
}
]
}
I have tried the mutate->gsub method but to no success.
Here is what my config file looks like
input {
file{
start_position => "beginning"
path => "XXX.json"
sincedb_path => "/dev/null"
codec => multiline {
pattern => "^Spalanzani"
negate => true
what => previous
auto_flush_interval => 1
multiline_tag => ""
}
}
stdin{}
}
filter {
mutate {
gsub => [ "[data][customData][value]", "\[", '"""[', "[data][customData][value]", "\]", ']"""' ]
}
json {
source => "message"
}
}
output {
stdout {codec => rubydebug}
elasticsearch {
hosts => "hostAddress"
user => "user"
password => "password"
index => "index"
}
}
Could anyone help me figure out how I could make it possible for me to insert three double quotes in front of my array to insert it as a string to ES?