Hello Guru's,
I have never ingested nested json before and I'm stuck.
Log examples:
{"system":"aa","logLevel":"[INFO]","log":{"0":"TT000000 joining provisioningEvent and will publish topics: provisioningEvent"}}
{"system":"bbb.ch","cid":"TT000000","sessionId":"1234567890","logLevel":"[INFO]","log":{"0":"clientHandler: sessionData","1.peripheral":"XX:XX:XX:XX:XX:XX","1.type":"E_RT_EEG_DATA_RCVD"}}
{"system":"bbb.ch","cid":"TT000000","sessionId":"1234567890","logLevel":"[INFO]","log":{"0":"clientHandler: sessionData","1.peripheral":"XX:XX:XX:XX:XX:XX","1.type":"E_RA_EEG_DATA_REQ_CMPLT"}}
{"system":"ad","logLevel":"[INFO]","log":{"0":"join","1":"{\"type\":\"socketJoin\",\"CID\":\"TT000000\",\"version\":\"com.xxx.app_xxxx_phone::1.0.0.001\",\"isClient\":true,\"value\":[{\"room\":\"TT000000\",\"publisherOfTopics\":[\"reduxAction\",\"sessionData\",\"sessionEvent\"]},{\"room\":\"provisioningEvent\",\"publisherOfTopics\":[\"provisioningEvent\"]}]}"}}
The errors I'm attempting to resolve:
"error"=>{"type"=>"document_parsing_exception", "reason"=>"[1:193] object mapping for [log.1] tried to parse field [1] as object, but found a concrete value"}}
"error"=>{"type"=>"document_parsing_exception", "reason"=>"[1:225] failed to parse field [log.1] of type [keyword] in document with id 'rsPop5ABzArOD7JdwIMC'. Preview of field's value: '{type=E_RA_EEG_DATA_REQ_CMPLT}'", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Can't get text on a START_OBJECT at 1:216"}}
I was attempting to correct it using dynamic_templates
"dynamic_templates": [
{
"strings_as_text": {
"match_mapping_type": "string",
"match": "log*",
"mapping": {
"type": "text"
}
}
},
{
"objects_as_object": {
"match_mapping_type": "object",
"match": "log*",
"mapping": {
"type": "object"
}
}
}
]
Configs:
input {
file {
path => "/logs/*.log"
start_position => "beginning"
}
}
filter {
mutate {
gsub => ["message", "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}:", ""]
}
json {
skip_on_invalid_json => true
source => "message"
}
}
output {
file {
path => "/logs/output.txt"
}
elasticsearch {
hosts => ["https://localhost:9200"]
ssl_certificate_verification => "false"
user => "elastic"
password => "PASWORD"
manage_template => false
data_stream => true
data_stream_type => "logs"
data_stream_dataset => "testing-8.11.1"
data_stream_namespace => "default"
action => "create"
}
}
But I'm not making any traction. I end up hitting the same errors above.
Any help would be greatly appreciated.
Best regards!