All Apps and Add-ons

Regex for Field Extraction

robhorton
Explorer

I've been trying to create a regex to generate a field name without success. The data I'm attempting to parse looks like:

logsrv> Message server exiting.

I would like to make logsrv represent a subsystem so that my field is subsystem and logsrv is the data for that field.

So far I have the following expression that works on a regex tester: ^.*?(?=>)
but I'm missing something with Splunk since it won't return any results no matter I try. The field extractor doesn't have any luck either when I try to create the expression using logsrv from the results.

Please help.

0 Karma

Rob
Splunk Employee
Splunk Employee

Have you tried testing this out with the rex command in Splunk with the search language?

|rex field=_raw "^(?<subsystem>[^>]+)>"

I am not sure if that will work if your raw event has anything before the "logsrv>" in the event line such as a timestamp.

robhorton
Explorer

Thank you! You're right. The data has the timestamp on the previous line and splunk returns results with the time and logsrv combined.

Data:
27-Jun-13 19:34:37
logsrv> Message server exiting.

Result:
27-Jun-13 19:34:37 logsrv

Do I need to search for a preceding carriage return or pattern match the time?

Thanks again!

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...