Getting Data In

Want to replace column name with today's date

sabari80
Explorer

I have a query to display following 3 fields 

| table pp_user_action_name,Today_Calls,Avg_today

i want to replace 'Avg_today' column header with today's date like '11/1/2023' 

is it possible? 

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Here's one method.  There may be others.

| makeresults 
| eval pp_user_action_name="foo",Today_Calls=42,Avg_today=3 
| table pp_user_action_name,Today_Calls,Avg_today
| rename Avg_today as 
    [| makeresults 
    ``` Get today's date and format it ```
    | eval today=strftime(now(), "%m/%d/%Y") 
    ``` Return only the value of the today field ```
    | return $today]
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Here's one method.  There may be others.

| makeresults 
| eval pp_user_action_name="foo",Today_Calls=42,Avg_today=3 
| table pp_user_action_name,Today_Calls,Avg_today
| rename Avg_today as 
    [| makeresults 
    ``` Get today's date and format it ```
    | eval today=strftime(now(), "%m/%d/%Y") 
    ``` Return only the value of the today field ```
    | return $today]
---
If this reply helps you, Karma would be appreciated.

sabari80
Explorer

its working. can we append any string with this date? For Ex: 11/1/2023_Response

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Sure!  Just use the concatenation operator (.) in the eval command.

| eval today=strftime(now(), "%m/%d/%Y") . "_Response"
---
If this reply helps you, Karma would be appreciated.
0 Karma

sabari80
Explorer

Thanks. i am all set. 

0 Karma
Get Updates on the Splunk Community!

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Dashboard Challenge and Watch the .conf24 Global Broadcast!

The Splunk Community Dashboard Challenge is still happening, and it's not too late to enter for the week of ...