Splunk Search

How do I select 2 lines in logs using regex?

badrinath
Path Finder

Hi,

I am working on logs so the logs can be of just one line or multiple lines and if it is of one line I wanted to take whole log where as if the log has multiple lines I wanted to consider only the first 2 lines.

please tell a possible solution using regex.

thanks in advance.

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex "^(?<lines>[^\n]+(\n[^\n]+)?)"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| rex "^(?<lines>[^\n]+(\n[^\n]+)?)"
Get Updates on the Splunk Community!

Using Machine Learning for Hunting Security Threats

WATCH NOW Seeing the exponential hike in global cyber threat spectrum, organizations are now striving more for ...

Observability Newsletter Highlights | March 2023

 March 2023 | Check out the latest and greatestSplunk APM's New Tag Filter ExperienceSplunk APM has updated ...

Security Newsletter Updates | March 2023

 March 2023 | Check out the latest and greatestUnify Your Security Operations with Splunk Mission Control The ...