Alerting

custom CSV filename with timestamp in email alerts

cramasta
Builder

I would like to customize the csv filename that gets sent in the email alerts while also including a time stamp in the file name.

Tags (4)
1 Solution

cramasta
Builder

i went poking around in the sendemail.py file.

What i ended up doing was commenting out the following line....

#filename = "splunk-results.csv"

And then I added the following two lines below it......

datestamp = time.strftime('%m-%d-%y')

filename = '%s-%s.csv' % (subject, datestamp)

What this ends up doing is naming the csv file with the email subject name that you define in the saved search and it also adds the timestamp to the end of filename as well.

mynewshinnyfilename-4-18-12.csv

View solution in original post

cramasta
Builder

i went poking around in the sendemail.py file.

What i ended up doing was commenting out the following line....

#filename = "splunk-results.csv"

And then I added the following two lines below it......

datestamp = time.strftime('%m-%d-%y')

filename = '%s-%s.csv' % (subject, datestamp)

What this ends up doing is naming the csv file with the email subject name that you define in the saved search and it also adds the timestamp to the end of filename as well.

mynewshinnyfilename-4-18-12.csv

vkakani60
Path Finder

Hope splunk team would consider your answer and modify the sendemail in coming releases. very helpful.

0 Karma

jbsplunk
Splunk Employee
Splunk Employee

It would be better if you could ask the question first with one post, and then post the answer to the question. After that you can accept your answer.

Get Updates on the Splunk Community!

Stay Connected: Your Guide to July Tech Talks, Office Hours, and Webinars!

What are Community Office Hours?Community Office Hours is an interactive 60-minute Zoom series where ...

Updated Data Type Articles, Anniversary Celebrations, and More on Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

A Prelude to .conf25: Your Guide to Splunk University

Heading to Boston this September for .conf25? Get a jumpstart by arriving a few days early for Splunk ...