Splunk Search

Creating unique file name for outputcsv

Motivator

I am trying to use this. It will create a file with the correct file name, it just has no contents... Any Ideas?

my command:

`eval_lab_invalid_chars` | `eval_lab_field_errors` | `remove_inactive_tests` | `lab_table_1` | `compendium_status_3_spaces` | `compendium_filter_status(Good)` | `report_date_grouping_lab` | `new_compendium_filter` | `division_lookup` | `compendium_date_format` | `compendium_new_lab_dedup` | `compendium_new_lab_table` | outputcsv [ search index=compendium sourcetype=lab_compendium | head 1 | eval query="All_lab_new_".strftime(now(),"%b_%d_%Y") | fields query | format "" "" "" "" "" ""]`

When I run the search without the outputcsv command I get results...

1 Solution

Motivator

We ended up using PowerShell to do the renames and moving the files to the Shared Location that we wanted to use. Changed outputcsv to outputlookup and setup some transforms.conf to setup the initial location of the files.

View solution in original post

0 Karma

Motivator

We ended up using PowerShell to do the renames and moving the files to the Shared Location that we wanted to use. Changed outputcsv to outputlookup and setup some transforms.conf to setup the initial location of the files.

View solution in original post

0 Karma

Motivator

I keep hearing that about a lot of the issues we deal with. I am beginning to wonder if there is something wrong with Windows!

0 Karma

Builder

very strange I have not had that happen in my experience so far.

0 Karma

Motivator

We are on 4.3.5

That is correct, if I use a static file name it works fine. When using the dynamic name I get a blank file.

I think we are just going to use PowerShell to add the date stamp to the file, after it is generated.

0 Karma

Builder

strange, what version are you running?
and to just be clear, when you define the file name like outputcsv filename.csv
its works
but when you use the unique name its a blank file?

0 Karma

Motivator

Tried that too, same result.

0 Karma

Builder

try this instead for creating the file name

...| outputcsv [ | stats count | eval filename=strftime(now(), "Alllabnew%b%d_%Y") | return $filename]

0 Karma

Motivator

That is correct, for 450 searches. This file will be used to maintain integrations.

0 Karma

Builder

what is the custom name you are trying to accomplish?
Alllabnewfeb27_2013.csv ?

0 Karma

Motivator

Yes, it will work that way.

0 Karma

Builder

so you if you just use ...|outputcsv somefile.csv
does it work?

0 Karma