Reporting

How do I export the search results for multiple searches to a single CSV file?

nbharadwaj
Path Finder

I need to run many searches and consolidate all the results. Each search looks like this

.......| stats count avg(field1) avg(field2)

So the output columns are always the same, and each search will only generate one row.

How can I send the output to one single CSV file? Is there a way to append to an existing CSV file?

I can go via the Web UI or via CLI- either way is fine. Thanks!

Tags (3)
0 Karma

Stephen_Sorkin
Splunk Employee
Splunk Employee

The most straightforward way is to use append:

... | stats count avg(field1) avg(field2) | append [search ... | stats count avg(field1) avg(field2)] | append [search ...] | ...

However, this isn't necessarily the most efficient.

Assuming that your initial search part is very simple, you can do something like:

(foo=A ...) OR (foo=B ...) OR (foo=C ...) | stats count avg(field1) avg(field2) by foo | fields - foo

Now, you may not have a field that cleanly splits the events. In that case you could use eval to synthesize one:

(<search A>) OR (<search B>) OR (<search C>) | eval foo = case(searchmatch("<search A>"), "A", ...) |  stats count avg(field1) avg(field2) by foo | fields - foo
0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...