Getting Data In

How to log date when report/query adds new values?

PTC_
Explorer

I have created a Report with a Query that updates a list of NAMES on CSV file.
If the NAMES field have empty strings or null values, the Query will try to get the NAME from another field and add it to NAMES. Something like this:

NAMES ADDED_ON_INDEX REPORT_UPDATE_DATE
Sara 01/03/2023 00:00:00 06/03/2023 17:28:17
John 01/02/2023 00:00:00 06/03/2023 17:28:17
Peter 01/01/2023 00:00:00 06/03/2023 17:28:17
     
Oliver 01/03/2023 00:00:00 06/03/2023 17:28:17

 

I want to achieve the following:

NAMES ADDED_ON_INDEX REPORT_UPDATE_DATE
Sara 01/03/2023 00:00:00 06/03/2023 17:28:17
John 01/02/2023 00:00:00 06/03/2023 17:28:17
Peter 01/01/2023 00:00:00 06/03/2023 17:28:17
Matt 22/01/2023 00:00:00 07/03/2023 18:33:09
Oliver 01/03/2023 00:00:00 06/03/2023 17:28:17

 

I want the Report to register the date ONLY when new values date and to NOT replace current dates, so I can keep track of when the NAMES were added by the Report.

I tried the following line but it doesn't do what I want. It always replace with the time the Report ran:

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

And "_time" gives me the date of when it was added to the index.

Is there a specific way to register this info?

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

To set a field only when it's null, use the coalesce command.

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

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

To set a field only when it's null, use the coalesce command.

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

 

---
If this reply helps you, Karma would be appreciated.

PTC_
Explorer

Is not updating the null fields with this command.
Any idea of what I could be doing wrong?

0 Karma

PTC_
Explorer

I did the inverse and it worked for my case:

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

 

Thank you!

richgalloway
SplunkTrust
SplunkTrust

It's possible the fields are not really null so coalesce doesn't touch them.

Can you share the full query and some sample data for it?

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...