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!

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...

SOCin’ it to you at Splunk University

Splunk University is expanding its instructor-led learning portfolio with dedicated Security tracks at .conf25 ...

Credit Card Data Protection & PCI Compliance with Splunk Edge Processor

Organizations handling credit card transactions know that PCI DSS compliance is both critical and complex. The ...