Hi,
I am trying to split into different events (logs) this log schema:
"_index": "cocacola",
"_type": "raw",
"_id": "CqwJ63MBEQS11DmXsDyRZl",
"_score": 1,
"_source": {
"messageId": 33297111461,
"eventType": "EntityUpdated",
"username": "Administrator",
"timeStamp": "2020-08-13T16:59:50.87Z",
"data": {
"name": "Target:1111111",
"definition": "Target",
"is_new": null,
"user_id": null,
"usergroup_id": null,
"rules": null,
"property_changes": [
{
"property": "Target.Completed",
"data_type": "System.DateTime",
"value": {
"original": null,
"new": "2020-08-13T16:59:50.8491889Z"
}
},
{
"property": "Target.State",
"data_type": "System.String",
"value": {
"original": "good",
"new": "very good."
}
},
{
"property": "Target.State",
"data_type": "System.String",
"value": {
"original": "Processing_Completed",
"new": "Completed"
}
}
into something like this:
"_index": "cocacola",
"_type": "raw",
"_id": "CqwJ63MBEQSDmXsDyRZl",
"_score": 1,
"_source": {
"messageId": 33291117461,
"eventType": "EntityUpdated",
"username": "Administrator",
"timeStamp": "2020-08-13T16:59:50.87Z",
"data": {
"name": "Target:1111111",
"definition": "Target",
"is_new": null,
"user_id": null,
"usergroup_id": null,
"rules": null,
"property_changes": [
{
"property": "Target.Completed",
"data_type": "System.DateTime",
"value": {
"original": null,
"new": "2020-08-13T16:59:50.8491889Z"
}
}
and this:
"_index": "cocacola",
"_type": "raw",
"_id": "CqwJ63MBEQSDmXsDyRZl",
"_score": 1,
"_source": {
"messageId": 3329111461,
"eventType": "EntityUpdated",
"username": "Administrator",
"timeStamp": "2020-08-13T16:59:50.87Z",
"data": {
"name": "Target:1111111",
"definition": "Target",
"is_new": null,
"user_id": null,
"usergroup_id": null,
"rules": null,
"property_changes": [
{
"property": "Target.State",
"data_type": "System.String",
"value": {
"original": "good",
"new": "very good."
}
}
I am using this but it doesn't work:
input {
elasticsearch {
hosts => ["https://xxxxxxxxxxx"]
index => "xxxxxxxxx"
user => "lxxxxxxxxxxxx"
password => "xxxxxxxxxxx"
query => '{ "qxxxxxxxxxxx" }}}'
}
}
filter {
json {
source => "message"
}
split {
field => "[data][property_changes]"
}
mutate {
add_field => {
"[user][name]" => "%{[username]}"
"[event][id]" => "%{[messageId]}"
"[event][type]" => "%{[eventType]}"
"[event][action]" => "%{[data][property_changes][property]}"
}
remove_field => ["message"]
}
}
output {
elasticsearch {
hosts => "https://xxxxxxxxxxxxxxxxxxx.xxxxxxxxxx"
index => "cxxxxxxxxxxx}"
user => "xxxxxxxxxxx"
password => "xxxxxxxxxx"
}
}
I have been checking multiple threads, some of them have a similar case like mine but it doesn't work when I try to adapt it to my situation. I tried something similar to this: Split nested json array
Maybe you can help @magnusbaeck since I have seen you in many threads. Could it work with a ruby plugin?