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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...