Splunk Search

How extract fields within my sample log?

ppanchal
Path Finder

Below is my log

Database-Error(3100)\nCONF-01083 - Count of positive/negative confirmations do not match the service quantity.  -> route order:152561611(61NX) / customer:699-0006223seq.nr:2\nCause: SQLException: ORA-20000: CONF-01083 - Count of positive/negative confirmations do not match the service quantity.  -> route order:152561611(61NX) / customer:699-0006223seq.nr:2\nORA-06512

I want to extract 3 fields,
152561611 as routeorder
61NX as route
699-0006223 as customer

Can somebody please assist me in achieving this?

0 Karma

woodcock
Esteemed Legend

Like this:

| rex "->\s*route\s*order:(?<routeorder>\d+)\((?<route>[^\)]+)\)\s*\/*\s*customer:(?<customer>[\d-]+)"
0 Karma

rphillips_splk
Splunk Employee
Splunk Employee

You can achieve this with a search-time field extraction on your search head in props.conf:
apply this the sourcetype,source,or host metadata
example using sourcetype:

$SPLUNK_HOME/etc/system/local/props.conf
[mysourcetype]
EXTRACT-fields = route\s+order\:(?<routeorder>\d+)\((?<route>\S+)\)\s+\/\s+customer\:(?<customer>\d+\-\d+)

0 Karma

DalJeanis
Legend

This will pull the first example of each field out of the _raw data.

| rex "route order:(?<routeorder>\d+)\s+?\((?<route>[^\)]*\))"
| rex "customer:(?<customer>[-0-9]*)"

Assumptions - (A) routeorder is always numeric (B )route is always found in parenthesis after the route, and does not contain any internal parenthesis, (C) customer consists solely of numbers and dashes.

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...