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!

Exciting News: The AppDynamics Community Joins Splunk!

Hello Splunkers,   I’d like to introduce myself—I’m Ryan, the former AppDynamics Community Manager, and I’m ...

The All New Performance Insights for Splunk

Splunk gives you amazing tools to analyze system data and make business-critical decisions, react to issues, ...

Good Sourcetype Naming

When it comes to getting data in, one of the earliest decisions made is what to use as a sourcetype. Often, ...