My logstash configuration is:
input {
tcp{
codec => json_lines {charset => "CP1251"}
...
}
}
output {
elasticsearch{...}}
But there is a problem that I can recieve string to already mapped as object field.
In that case in elasticsearch occures an error and I lose this line in the results:
org.elasticsearch.index.mapper.MapperParsingException: object mapping for [detail.data.response.body] tried to parse field [body] as object, but found a concrete value
I tried mutate/replace or
filter
{
if [detail][data][response][body]
{
if [detail][data][response][body] == "Unauthorized"
{
json_encode
{
source => "[detail][data][response][body]"
}
}
}
}
The mapping of detail.data.response.body is inconsistent with the data you're attempting to index. What kind of value(s) shoulddetail.data.response.body contain? An object or a value? What are you trying to index? Comment out the elasticsearch output and add a stdout { codec => rubydebug } output.
As usual it comes as json:
"body":{"values":[], etc}
But sometimes I recieve
"body":"Unauthorized"
or
"body":"Not Found"
I would like to replace this kinds of strings with
"body":{"thesebeautifulpeoplegavemeastring":"Unauthorized"}
or
"body":{"thesebeautifulpeoplegavemeastring":"Not Found"}
[2017-10-05T17:16:21,702][DEBUG][o.e.a.b.TransportShardBulkAction] [test_node_name] [logstash-2017.10.05][1] failed to execute bulk item (index) BulkShardRequest [[logstash-2017.10.05][1]] containing [10] requests
org.elasticsearch.index.mapper.MapperParsingException: object mapping for [detail.data.response.body] tried to parse field [body] as object, but found a concrete value
Create strings once as Ruby Constants in the plugin initialization. This prevents unnecessary string creation for every filter invocation - the event.set will deconstruct the path reference into new string parts internally anyway so a new string each time is a waste.
Freeze the Constants, this will prevent other code from changing them.
Extract the value to a local variable once and reuse.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.