New to splunk.
This query Runs perfectly fine via the UI:
index=serverlogs* WEB_URL=/someurl/* | rex ".*\?(?<GETQUERY>[^ ]+)" | search GETQUERY=*.jpg | top 20 REFERER
I'm trying to apply this to the REST API as such and every rex fails and sends back: Error in 'SearchParser': Missing a search command before '^'
It always sends back whatever special character is in the brackets []. Is there a way to use "rex" over the API using brackets in my regex? or to be able to use regex to extract a field on the fly?
Here's my query:
curl -k https://myhost:8089/servicesNS/-/search/search/jobs/export -u user:passwd -d search="search index%3Dserverlogs* WEB_URL%3D/someurl/* | rex \".*\%3F(%3F<GETQUERY>[^ ]+)\" | search GETQUERY%3D*.jpg | top 20 REFERER" -d earliest_time="-10m" -d latest_time="now" -d output_mode="csv" > output.csv
Any suggestions?