Splunk Search

How to use REX in a search called via REST API?

Stuartb_
New Member

In my first post,

I need to search Splunk using the REST API. How do I get the system to actually return me some results?

Steps

  1. POST a search, example: 

 

 

search=search index=myIndex earliest=-1d "[nice-keyword]" AND "Nice catch-phrase" | rex field=_raw "reportingSystem\":\s+\"(?<system>\d{3})[\s\S]+operationCode\":\s+\"(?<opcode>\w+)[\s\S]+ticketId\":\s+\"(?<ticket>\d*)[\s\S]+transactionCode\":\s+\"(?<txcode>\w+)[\s\S]+NumericCode\":\s+\"(?<agency>\d*)" | table system, opcode, txcode, agency​

 

 

  • In the SEARCH User Interface, this makes a nice report
  • Grab the job search ID.
  • Continually GET the job status of the POSTed search until DONE or something else that helps me stop polling.
  • Ask for the job results. Get 200 OK but no content.

How does one actually format a search that can provide actual results via the API?

Stumped. For days. I'm using Postman before moving on to my favorite middleware tool.

Thank you.

Labels (2)
0 Karma

Stuartb_
New Member

Having found that url encoding works well (thanks to other posters), I have made some progress! Next to work out how to find the eventId and to be able to do a JOIN in the same search via API.

0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...