Splunk Search

Number of fields occurrence in json data

govindparashar1
New Member

I have below data

`
{ [-]
context: { [+]
}
level: INFO
logger: x.x.x.xxx.service.xxxService
msg: Filtered statements for account XXXXX: DocumentReferences[references=[DocumentReference[reference=0000001,name=XXXXX_2019,mimeType=APPLICATION_PDF,documentType=ANNUAL_STATEMENT,creationDate=2019-11-18T13:37:13.000Z], DocumentReference[reference=0000002,name=XXXXX_2018,mimeType=APPLICATION_PDF,documentType=ANNUAL_STATEMENT,creationDate=2019-12-03T10:54:47.000Z], DocumentReference[reference=0000003,name=XXXXX_2017,mimeType=APPLICATION_PDF,documentType=ANNUAL_STATEMENT,creationDate=2019-12-03T11:00:52.000Z]]]

}
`
I want to search more than one ANNUAL_STATEMENT occurrence . As above data have 3 statement then this result should return in table

Tags (3)
0 Karma

dindu
Contributor

Hi Govind,

You need to parse the JSON logs to achieve this.
To parse the logs - you need to trim down the events to make it as exact JSON Splunk expects.
Use regex or replace functionality for that.

You could use the below query after that.

|your_query
|search documentType="ANNUAL_STATEMENT"
|stats list (reference),list(name),list(mimeType),list(documentType),list(creationDate)
|where mvcount(documentType)>1
0 Karma

Anantha123
Communicator

Hi ,

try this

base query| spath | stats count(**documentType) as DocType, values(**reference) as Reference , values(**name) as Name by **msg| rex field=**msg "Filtered\sstatements\sfor\saccount\s(?P<AccountNo>[^\:]+)" | search DocType > 1 | table AccountNo , Name, Reference, DocType.

Here when we use spath , fields are automatically extracted . Choose the right field name that is under interesting fileds and put in above query and try .

Thanks
Anantha.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...