Hi Team,
I'm trying to parse a JSON data through logstash. I'm using JSON and split plugins to parse the data.
Below is my format of my JSON message.
{
agentId: "TMS",
apiVersion: "v2",
entities: [
{
agentId: "Server1",
name: "HouseBankID",
cacheManagerName: "RFT_HouseBank_CacheMgr",
attributes: {
Size: 21,
LocalHeapSize: 0,
CacheInMemoryMissRate: 0,
LocalHeapSizeInBytes: 0,
AverageGetTime: 0,
CacheHitRate: 0,
CacheOffHeapMissRate: 0,
LocalOffHeapSize: 0,
CacheInMemoryHitRate: 0,
CacheMissRate: 0,
CacheHitRatio: 0,
CacheOffHeapHitRate: 0
}
},
{
agentId: "Server2",
name: "HouseBankID",
cacheManagerName: "RFT_HouseBank_CacheMgr",
attributes: {
Size: 21,
LocalHeapSize: 0,
CacheInMemoryMissRate: 0,
LocalHeapSizeInBytes: 0,
AverageGetTime: 0,
CacheHitRate: 0,
CacheOffHeapMissRate: 0,
LocalOffHeapSize: 0,
CacheInMemoryHitRate: 0,
CacheMissRate: 0,
CacheHitRatio: 0,
CacheOffHeapHitRate: 0
}
}
],
exceptionEntities:
}
But I'm getting a parsing exception
exception=>#<LogStash::Json::ParserError: Unexpected character ('' (code 92)): was expecting double-quote to start field name
To my knowledge, A JSON data should be enclosed with in double quote like "field" : "value"
So is there any work around so that I can add double quotes to each and every line of JSON data. So that It's in a valid format to be parsed using a Json filter in logstash.
Below is my logstash configuration.
input {
beats {
port => 5044
}
}
filter{
mutate {
gsub => [
'message' , '},' , '}'
]
}
json {
source => "message"
}
split {
field => "entities"
}
}
output{
stdout {
codec => rubydebug
}
}
It'd be of great help if anyone guide me with parsing this JSON data as expected.
Thank you in advance