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!

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 ...

Join Us at the Builder Bar at .conf24 – Empowering Innovation and Collaboration

What is the Builder Bar? The Builder Bar is more than just a place; it's a hub of creativity, collaboration, ...

Combine Multiline Logs into a Single Event with SOCK - a Guide for Advanced Users

This article is the continuation of the “Combine multiline logs into a single event with SOCK - a step-by-step ...