Splunk Search

Rest API quote escape

zubairaizatron
Explorer

Hi guys

I'm trying to run a search to the /jobs endpoint. however I get a 

bash: syntax error near unexpected token `('

error message.

my search has quotes in it for a | rex command and I tried escaping the quotes with the \ but is till seem to get the issue. when using the \ I get a 

<msg type="ERROR">Unparsable URI-encoded request data</msg>

error.

My search is structured as follows:

|  tstats summariesonly=1 values(<values>) ....(there are a lot of these) from datamodel=<name> WHERE (some values for the previous section) | lookup <lookup> | rex field=<name> "(?<new field name>[^.]{9}$)" ... 

there are about 4 lookups in total and 2 rex command. however when i try to escape in the rex command I get the Unparsebale URI error.

 

Anybody come across this error before?

 

Labels (3)
0 Karma

johnhuang
Motivator

Parenthesis are special characters in bash. You can escape with \

| rex field=<name> "\(?<new field name>[^.]{9}$\)" ... 


Or encapsulate the entire SPL with single quote '

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The "bash:" portion of the error message indicates this is a shell problem rather than a Splunk problem.  It would help to see the complete CLI command, but I suspect you just need to put quotation marks around the entire search command (and escape quotation marks within it).

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...