All Apps and Add-ons

How to search a string ?

ashukp
Loves-to-Learn Lots

Request={"headers":{"zip":"500000"}},"location":"HYD","info":[{"phoneNumber":"******6467","test":[{"id":"1234"}]}],"testing123":{"tenure":1234,"stringvalue":"A"}}}

 

How can search for "stringvalue":"A"?

 

I tried | makemv tokenizer="([^,]+)," Params | mvexpand line
| rex field=Params "(?<key>[^{'stringvalue'':']+) : (?<value>[A]+)" It did not work.

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @ashukp,

do you want to search or to extract field?

if you want to search you can use the regex command:

| makeresults
| eval _raw="Request\=\{\"headers\":\{\"zip\":\"500000\"\}\},\"location\":\"HYD\",\"info\":\[\{\"phoneNumber\":\"******6467\",\"test\":\[\{\"id\":\"1234\"\}\]\}\],\"testing123\":\{\"tenure\":1234,\"stringvalue\":\"A\"\}\}\}"
| regex  "\"stringvalue\":\"[^\"]+\""

if instead you want to extarct the value after "stringvalue", you have to use the rex command:

| makeresults
| eval _raw="Request\=\{\"headers\":\{\"zip\":\"500000\"\}\},\"location\":\"HYD\",\"info\":\[\{\"phoneNumber\":\"******6467\",\"test\":\[\{\"id\":\"1234\"\}\]\}\],\"testing123\":\{\"tenure\":1234,\"stringvalue\":\"A\"\}\}\}"
| rex  "\"stringvalue\":\"(?<stringvalue>[^\"]+)\""

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Splunk MCP & Agentic AI: Machine Data Without Limits

  Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization ...

Finding Based Detections General Availability

Overview  We’ve come a long way, folks, but here in Enterprise Security 8.4 I’m happy to announce Finding ...

Get Your Hands Dirty (and Your Shoes Comfy): The Splunk Experience

Hands-On Learning and Technical Seminars  Sometimes, you just need to see the code. For those looking for a ...