Splunk Cloud Platform

To add timestamp in report mail

MsF-2000
Path Finder

Hi All

We got this requirement to print the timestamp in mail subject for scheduled report. the timestamp should indicate the time it got sent.

for exg, the report runs twice a day so if it runs 6 am and 6 pm, the mail subject should indicate dd-mm-yyyy 06:00:00 or 18:00:00

Please help.

Labels (1)
0 Karma
1 Solution

livehybrid
SplunkTrust
SplunkTrust

Hi @MsF-2000 

You may be able to use $job.latestTime$ in your subject - however I believe this is a unix timestamp so it may be hard for the receiver to know what it really means.

Instead, you could use add_info to your search to get the search time and use the $result.search_time$

livehybrid_0-1744872515247.png

 

index=_internal | stats count
| addinfo
| eval search_time=strftime(info_search_time,"%c")
| fields - info_*

This is a simple example to help you get started.

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

View solution in original post

livehybrid
SplunkTrust
SplunkTrust

Hi @MsF-2000 

You may be able to use $job.latestTime$ in your subject - however I believe this is a unix timestamp so it may be hard for the receiver to know what it really means.

Instead, you could use add_info to your search to get the search time and use the $result.search_time$

livehybrid_0-1744872515247.png

 

index=_internal | stats count
| addinfo
| eval search_time=strftime(info_search_time,"%c")
| fields - info_*

This is a simple example to help you get started.

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

MsF-2000
Path Finder

Hi @livehybrid 

 

I checked with the query and it worked, I made little change to display DD:MM:YYYY HH:MM:SS using below query and it worked as expected. I am marking your answer as solution since it gave me base query to develop from, thank you very much !

 

|eval timestamp=strftime(now(), "%d/&m/%Y %H:%M:%S")

|table timestamp,<<intented fields>>

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...