Splunk Search

How do I extract a field between two strings using a regular expression?


I have logs having string like:|> GET /alldata|> GET /somedata|> GET /nodata|> POST /nodata|> PUT /nodata|> DELETE /nodata

I want to extract the field between|> and /
i.e i need GET,POST,PUT,DELETE to be in an extracted field.

NOTE: There's a space after > and before /

0 Karma


Hi @rohanmiskin

Try this and let me know

| makeresults 
| eval sampledata ="|> GET /somedata" 
| rex field="sampledata" ">\s(?P<method>.*)\s\/"
0 Karma


@rohanmiskin ,


Happy Splunking!
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...