Hi ,
When I load Json file to ElasticSearch , I sea the data in 1 column (message ).
For example:
{"Group": "abi", "ExTime": "", "LastSuccess": "", "PadDG%": "", "TestName": "PT_FOTA/abi/SUPPORT/test132", "WI": "", "TWrtRatio": "", "B-Error": "", "IMG-FS.DG%": "", "BupgRet": "0", "Policy": "", "Ratio": "", "B-DeltaSize": "0.161", "WrtRatio": "", "B-Fail-On": "", "Status": "Missing", "WrittenGap": "", "PadDelta": "", "Hash": "Miss", "Description": "", "Tags": "abi sr fsimg", "TargetImg": "", "lookUpStr": "", "TotalTime": "", "GenTime": "", "Base HTML": "http://qasrvlinux/Results/9.4/9.4.1.7/linux/PT_FOTA/abi/SUPPORT/test132/HTML/RUN/8A01021D-D8AB8450-9D170943.html", "FileDG%": "", "HTML": "http://qasrvlinux", "DeltaSize": "", "SourceImg": "", "B-ExTIme": "1", "B-TWritten": "", "B-GenTime": "5", "VersionParam": "", "RamGap%": "", "DG%": "", "TWrittenGap": "", "FileDelta": "", "SrcSize": "", "B-MinRam": "3.915", "TrgSize": "", "B-FileDelta": "", "B-LastSuccess": "PCUA 64b SimulateReset", "RamSize": "", "upgRet": "", "Range": "7", "IsOct": "No", "DeltaGap": "", "Error": "", "B-ErrType": "", "MinRam": "", "ExGap": "", "TWritten": "", "RamGap": "", "Fail-On": "", "NumBck": "", "Agent": "", "Bstatus": "Pass", "ramRatio": "", "ReqID": "", "SecSize": "", "GenGap": "", "ErrType": "", "B-Ratio": "", "B-PadDelta": "", "Subject": " abi"}
I upload the data to ElasticSearch with logstash , this is the conf file:
input {
file{
path => ["/root/scripts/logs/update/tmp1.json"]
type => "json"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter{
grok {
match => [ 'message', '(?"TestName":.*"Agent":"[^"]+")' ]
add_field => [ "json_body", "{%{body}}" ]
}
json {
source => "json_body"
remove_field => ["message","body","json_body"]
}
mutate {
add_field => ["[geoip][location]","%{[SrcSize]}"]
add_field => ["[geoip][location]","%{[TrgSize]}"]
add_field => ["[geoip][location]","%{[B-DeltaSize]}"]
add_field => ["[geoip][location]","%{[DeltaSize]}"]
add_field => ["[geoip][location]","%{[B-Ratio]}"]
add_field => ["[geoip][location]","%{[Ratio]}"]
add_field => ["[geoip][location]","%{[B-MinRam]}"]
add_field => ["[geoip][location]","%{[MinRam]}"]
add_field => ["[geoip][location]","%{[ramRatio]}"]
add_field => ["[geoip][location]","%{[RamGap]}"]
add_field => ["[geoip][location]","%{[RamGap%]}"]
}
mutate {
convert => [ "[geoip][location]", "float"]
}
}
output {
stdout {
codec => rubydebug
}
elasticsearch {
host => "10.XX.XX.XXX"
protocol => "http"
index => "index_update"
}
}
If I want each one of the row will be in a separated column , how can I do it ?
BR,
Chen