Splunk Search

How to maintain format into variables

gerardo_maya
Splunk Employee
Splunk Employee

I want to extract part of an event that is multi-line and tab formated, the event lokks like this:

11:19:29.000 PM
7.05 0.00 (1343189969 083501): Query a ejecutar: SELECT prop_account, description
FROM tracking.google_analytics_web_properties
WHERE prop_type = 'qa'
AND home = 'es_cl'
AND portal = '*'

I want to extract from Query I use a regex and I have a variable called Message. But when I displayed it Splunk truncate the message.

1 Query a ejecutar: SELECT prop_account, description

I am using this search command:

sourcetype="xtype" query | rex field=_raw "):\s(?.+)" | table Message

Any idea could be great.

Tags (1)
0 Karma

gerardo_maya
Splunk Employee
Splunk Employee

Professional services recommend me to do the following:
sourcetype="xtype" query | eval long_str=replace(_raw, "\n", "###") | rex field=long_str "):\s(?.+)" | makemv delim="###" Message | table _time Message

The second part of the search replaces the new lines for a know pattern (on this case ###).
Then you use REGEX to capture the field from the long_str
Using makemv you break the lines when it found the pattern "###"
Lastly you present the data into a table, this is the result.

Query a ejecutar: SELECT prop_account, description FROM tracking.google_analytics_web_properties
WHERE prop_type = 'qa' AND
home = 'es_cl' AND portal = '*'

0 Karma

lguinn2
Legend

Try

sourcetype="xtype" query | rex field=_raw "(?m)):s(?<message>.+)" | table Message

The (?m) tells the regex to work across line breaks.

0 Karma

gerardo_maya
Splunk Employee
Splunk Employee

Thank you, that works to capture all data into the variable but it does not maintain the line breaking inside the Message Variable

0 Karma
Get Updates on the Splunk Community!

Operationalizing TDIR: Building a More Resilient, Scalable SOC

Optimizing SOC workflows with a unified, risk-based approach to Threat Detection, Investigation, and Response ...

Pro Tips for First-Time .conf Attendees: Advice from SplunkTrust

Heading to your first .Conf? You’re in for an unforgettable ride — learning, networking, swag collecting, ...

Raise Your Skills at the .conf25 Builder Bar: Your Splunk Developer Destination

Calling all Splunk developers, custom SPL builders, dashboarders, and Splunkbase app creators – the Builder ...