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!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...