Splunk Search

download specific CSV columns via the web API?

rwgilt
Explorer

What I want to do is pull down the results of a saved search as a CSV file, which will then be loaded into a data warehouse. I would like to automate this on a nightly basis, so I'm experimenting with the web api.

I've successfully been able to pull down the results of the search I want via the web API, but am running into two issues which I have not found info about in the docs:

  1. When I browse through the results with the web interface, I get 2600 results. However, I'm only getting about 200 in the csv I'm pulling down. How do I get the rest of the result set?

  2. Can I somehow set up the saved search so I only get the fields I am interested in, rather than the other 100 fields I don't care about?

Tags (4)

Stephen_Sorkin
Splunk Employee
Splunk Employee

I assume that you're using the REST API like:

GET /services/search/jobs/<sid>/results?output_mode=csv

If this is the case, there are two arguments to add, field_list and count:

GET /services/search/jobs/<sid>/results?output_mode=csv&field_list=<comma separated field list>&count=0

If you want to page through the results for efficiency, you can use the offset argument in addition to the count argument and make several requests.

Stephen_Sorkin
Splunk Employee
Splunk Employee
0 Karma

rwgilt
Explorer

ps: is this info in the docs somewhere?

0 Karma

rwgilt
Explorer

This does just what I need - thanks!

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...