Splunk Search

Regex search help?

monicateja
Explorer

log: {“timeMillis”:“1667091964927",“timestamp”:“2022-10-30T01:06:04.927Z”,“thread”:“reactor-http-epoll-3",“level”:“INFO”,“logger”:“com.status”,“message”:“Business Key=null, Publishing  status : [ client_req_id fd6e03ea-99ed-4f0c-b52f-db7ceca0adc8, event_date 2022-10-30T01:06:04.927Z, event_name STORE_EXIT_AUDIT_RESULT, request_source RECEIPT_AUDIT_SERVICE ] message {“receipts”:[{“tc_id”:“20420249182009622534”,“tc_date”:“2022-10-30T01:06:04.927Z”,“tc_store_id”:“92”,“tc_operator_number”:“11”,“tc_register_number”:“11”,“tc_audit_status”:“SUCCESS”,“tc_previously_audited”:false,“tc_previously_audited_date”:null}],“audit_result”:{“audit_date”:“2022-10-30T01:06:03.846Z”,“audit_store_id”:“92",“audit_associate_id”:“103956635",“audit_result”:“Pass”,“audit_failure_reason”:null,“scanned_items_number”:3,“items_found”:[],“items_not_found”:[]}}” ,“traceId”:“”, “spanId”:“”, “parentSpanId”:“”, “traceparent”:“”, “tracestate”:“”, “message_code”:“”, “flag”:“”, “tenant”: “”, “businessKey”:“”, “ringId”:“”, “locationNumber”:“”, “dc”:“”}

I want to see Store exit result with operator number, store id, register number , audit result , scanned items number , items found , items not found and also audit date , tc_id, timestamp in a table with those values.

can anyone please 

 

Labels (4)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

As I always tell people, do not attempt regex on structured data like JSON.  So, my first question is: How faithful is that sample event in terms of format?  I ask because the quotation marks used are all over places. This inconsistency makes me doubt the fidelity of the rest of format.  After correcting for inconsistent quotation marks, the part that belongs to "log" is still not conformant JSON.

If the log is truly this messy, you can take consolation that a small, but key part of the log is still conformant.  Instead of starting with "log" field, I have to start from that second "message".

 

| rex "message: (?<in_message>{.+}})"
| spath input=in_message path=receipts{}
| mvexpand receipts{}
| spath input=receipts{}
| spath input=in_message path=audit_result
| spath input=audit_result
| fields - data log in_message _time audit_result receipts{}

 

After this, you can expect something like

audit_associate_idaudit_dateaudit_failure_reasonaudit_store_idscanned_items_numbertc_audit_statustc_datetc_idtc_operator_numbertc_previously_auditedtc_previously_audited_datetc_register_numbertc_store_id
1039566352022-10-30T01:06:03.846Znull923SUCCESS2022-10-30T01:06:04.927Z2042024918200962253411falsenull1192

I think these are the fields that you wanted.

Tags (1)
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...