Reporting

use source name as outputcsv filename

ryastrebov
Communicator

Hello!
It is possible? If yes, how this can be done?

Tags (2)
0 Karma
1 Solution

cramasta
Builder

This will output a csv using the source of the data set you are searching against. It should work for both linux and window file paths

index=foo sourcetype=bar | outputcsv [ index=foo sourcetype=bar | head 1| eval search = replace(source, ".*/|.*\\\|\.\w+", "") | fields search]

This example will give you the source file name plus add the current timestamp to the end of the filename

index=foo sourcetype=bar | outputcsv [ index=foo sourcetype=bar | head 1| eval search = replace(source, ".*/|.*\\\|\.\w+", "") | eval search=strftime(now(), search."_%Y%m%d%H%M%S") | fields search]

View solution in original post

ryastrebov
Communicator

Thank you for your comment!

0 Karma

cramasta
Builder

This will output a csv using the source of the data set you are searching against. It should work for both linux and window file paths

index=foo sourcetype=bar | outputcsv [ index=foo sourcetype=bar | head 1| eval search = replace(source, ".*/|.*\\\|\.\w+", "") | fields search]

This example will give you the source file name plus add the current timestamp to the end of the filename

index=foo sourcetype=bar | outputcsv [ index=foo sourcetype=bar | head 1| eval search = replace(source, ".*/|.*\\\|\.\w+", "") | eval search=strftime(now(), search."_%Y%m%d%H%M%S") | fields search]

ryastrebov
Communicator

Thank you, cramasta!
This is exactly what I need!

0 Karma

jonuwz
Influencer

Having dynamic output filenames is possible. I use it to output files with the date. Post an example search since the technique varies. The all use sub searches with "return" though.

0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

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 ...