I have nested JSON log files which I'm trying to parse and ship to my ES v.5
My logstash version is also 7.5.
The problem is among for instance 3000 logs I get 250 _jsonparsefailure!
My log format is nested JSON.
here is my logstash config file:
file {
path => "/home/kasra/test/*.log"
codec => json { charset => "UTF-8"}
}
}
filter {
json {
source => "message"
# skip_on_invalid_json => "true"
}
geoip {
source => "sourceIpAddress"
target => "GeoLocation"
fields => ["city_name", "country_name", "region_name", "location"]
}
date {
match => ["eventTime", "ISO8601"]
locale => en
timezone => "Asia/Tehran"
target => "@timestamp"
}
}
output {
elasticsearch {
hosts => ['X.X.X.X:9200']
index => ["ali-%{+YYYY.MM.dd}"]
user => "XXXX"
password => "XXXX"
}
}
and here is my sample log which usually have it corrupted and broken by logstash into 2 or 3 logs..
[{"acsRegion":"test","additionalEventData":{"Scheme":"https"},"apiVersion":"2016-11-11","eventId":"CA6D8ACD-884D-461A-AFBE-35B81D43036C","eventName":"AttachPolicy","eventSource":"resourcemanager-share","eventTime":"2020-01-12T08:43:36Z","eventType":"ApiCall","eventVersion":"1","referencedResources":{"Policy":["test"]},"requestId":"CA6D8ACD-884D-461A-AFBE-35B81D43036C","requestParameters":{" charset":"UTF-8","PrincipalName":"test.com","AcceptLanguage":"en-US","SDSDSD":"asdasd","PolicyName":"testAccess","ResourceGroupId":556422749542138042,"RequestId":"CA6D8222ACD-884D-4261A-AFBE-35B81D43036C","HostId":"test2.com","PrincipalType":"IMSUser","PolicyType":"System"},"serviceName":"ResourceManager","sourceIpAddress":"y.x.z.z","userAgent":"Apache-HttpClient/4.5.7 (Java/1.8.0_152)","userIdentity":{"accountId":"556474922222542","principalId":"556433954213","sessionContext":{"attributes":{"creationDate":"2020-01-12T08:43:35Z","mfaAuthenticated":"false"}},"type":"test-account","userName":"test"}},{"acsRegion":"test","additionalEventData":{"Scheme":"https"},"apiVersion":"2016-11-11","eventId":"2BBED315-ABA2E-44E3EE-99335A-96sss265A69904C","eventName":"ListPolicyAttachments","eventSource":"resourcemanager-shsdsdsd.com","eventTime":"2020-01-12T08:43:40Z","eventType":"ApiCall","eventVersion":"1","requestId":"2BBED315-AB2E-44EE-995A-965904C","requestParameters":{" charset":"UTF-8","AcceptLanguage":"en-US","SDSDSDSVVV":"asd","RequestId":"2BBED3-ASSB2E-43334EE-995A-96265A69904C","HostId":"resourcemanager-sdsdsdds.com"},"serviceName":"ResourceManager","sourceIpAddress":"xx.xx.x.xx","userAgent":"Apache-HttpClient/4.5.7 (Java/1.8.0_152)","userIdentity":{"accountId":"5232323232323","principalId":"5353535353535353535","sessionContext":{"attributes":{"creationDate":"2020-01-12T08:43:39Z","mfaAuthenticated":"false"}},"type":"test-account","userName":"test"}},{"acsRegion":"test","additionalEventData":{"Scheme":"https"},"apiVersion":"2016-11-11","eventId":"BEsdsdsdsd-4B1C-BDED-50ssdsdSDSDSDECE5","eventName":"AttachPolicy","eventSource":"resourcemanager-shsdsdsdsd.com","eventTime":"2020-01-12T08:44:00Z","eventType":"ApiCall","eventVersion":"1","referencedResources":{"Policy":["AdministratorAccess"]},"requestId":"BE1DSDSD6079-49AE-4B1C-BDED-50SDSDSD1DE5","requestParameters":{" charset":"UTF-8","PrincipalName":"test@test.com","AcceptLanguage":"en-US","AFFSF":"asdasd","PolicyName":"AdministratorAccess","ResourceGroupId":556474954213823232323042,"RequestId":"BE1D6SDSDSD079-41213239AE-4B1sdsdSDSDC-BDED-501DA82EECE5","HostId":"resourcemanager-shsdsdsdsd.com","PrincipalType":"AASCUser","PolicyType":"System"},"serviceName":"ResourceManager","sourceIpAddress":"XX.XX.X.X","userAgent":"Apache-HttpClient/4.5.7 (Java/1.8.0_152)","userIdentity":{"accountId":"5562323232542138042","principalId":"556423232338042","sessionContext":{"attributes":{"creationDate":"2020-01-12T08:43:59Z","mfaAuthenticated":"false"}},"type":"test-account","userName":"test"}},{"acsRegion":"test","additionalEventData":{"Scheme":"http"},"apiVersion":"2017-04-30","eventId":"CEBFE232323E06-F7C4-4B64-8FBF-7A6D61F47780","eventName":"ListGroups","eventSource":"Aas-shasdasdasdasd.com","eventTime":"2020-01-12T08:44:10Z","eventType":"ApiCall","eventVersion":"1","requestId":"CEBFESDSDSD23E06-F7SD2C4-4SD23B64-8FSD23BF-7A6SD23D61F47780","requestParameters":{"MaxItems":1000," charset":"UTF-8","AcceptLanguage":"en-US","AAAP":"rsd","RequestId":"CEBFSDSDSDEE06-FSDSD7C4-4SDSDB64-8FSDSDBF-7A6D232323SDSD610","HostId":"ssds-shasdsdsd.com"},"serviceName":"Asd","sourceIpAddress":"X.XX.X.X","userAgent":"Apache-HttpClient/4.5.7 (Java/1.8.0_152)","userIdentity":{"accountId":"556232323232342","principalId":"556343434343434042","sessionContext":{"attributes":{"creationDate":"2020-01-12T08:44:10Z","mfaAuthenticated":"false"}},"type":"test-account","userName":"test"}},{"acsRegion":"test","additionalEventData":{"Scheme":"http"},"apiVersion":"2017-04-30","eventId":"1E01123235FB8-32323530-4E232321-B12323EB-523239C0DB7AEAA1","eventName":"GetUser","eventSource":"asd-shasdsdsdd.com","eventTime":"2020-01-12T08:44:48Z","eventType":"ApiCall","eventVersion":"1","referencedResources":{"User":["testsssdsdsdaax.com"]},"requestId":"1E02323232315FB8-353232323230-4E2321-B1EB-59C0ASDASD23DDVB7AEAA1","requestParameters":{" charset":"UTF-8","AcceptLanguage":"en-US","SDS":"asdsd","RequestId":"1E023232315FB8-35232330-42323E21-B12323EB-59C02323DB7AEAA1","HostId":"sdsd-shasdsdsdsd.com","UserPrincipalName":"testttt.com"},"serviceName":"asd","sourceIpAddress":"XX.XX.XX.XX","userAgent":"Apache-HttpClient/4.5.7 (Java/1.8.0_152)","userIdentity":{"accountId":"55647424443434","principalId":"556455555343434","sessionContext":{"attributes":{"creationDate":"2020-01-12T08:44:47Z","mfaAuthenticated":"false"}},"type":"test-account","userName":"test"}},{"acsRegion":"testtttt","additionalEventData":{"Scheme":"https"},"apiVersion":"2016-11-11","eventId":"4sdsdsdds57-633434-VF0E-AADA-80C4D5155F","eventName":"ListPolicyAttachments","eventSource":"resourcemanager-shasdasdasd.com","eventTime":"2020-01-12T08:44:50Z","eventType":"ApiCall","eventVersion":"1","requestId":"45023232323DE9B7-6402323234-4A0E-A2DA-82323232323155F","requestParameters":{" charset":"UTF-8","PrincipalName":"test@test.com","AcceptLanguage":"en-US","ASDDSX":"asd","RequestId":"45232323230DE9B7-6232323404-4A5550E-A2DA-80C4D995155F","HostId":"resourcemanager-sharsdasdasd.com","PrincipalType":"ISDSD"},"serviceName":"ResourceManager","sourceIpAddress":"XX.XX.XX.XX","userAgent":"Apache-HttpClient/4.5.7 (Java/1.8.0_152)","userIdentity":{"accountId":"4444444444444444555","principalId":"5555555554433","sessionContext":{"attributes":{"creationDate":"2020-01-12T08:44:49Z","mfaAuthenticated":"false"}},"type":"test-account","userName":"test"}}]
therefore I've got lots of ERROR in logstash which shows there are Json::ParserErrors
it tries to parse broken logs which are not in JSON format obviously!