All Apps and Add-ons

How to add a space when renaming a field?

p1stolero
Explorer

I have a search using Timewrap that compares today against last week for the same week day. I'm having issues with renaming the field "1week_before" so it displays as "Last Tuesday". The search fails with

Error in 'rename' command: Usage: rename [old_name AS/TO/-> new_name]+

any time I try adding a space so the closest I've been able to get is "Last_Tuesday". Is there a way to do this?

earliest="-w@w" latest="+w@w" index="_internal" sourcetype="scheduler" 
| timechart span=10m count 
| timewrap w 
| where strftime(_time,"%A") == strftime(now(), "%A")
| rename latest_week as Today 
| rename 1week_before as [| stats count | eval tmp=strftime(now(), "%A") | eval str="Last_".tmp | return $str]
0 Karma
1 Solution

somesoni2
Revered Legend

There are multiple options

 earliest="-w@w" latest="+w@w" index="_internal" sourcetype="scheduler" 
 | timechart span=10m count 
 | timewrap w 
 | where strftime(_time,"%A") == strftime(now(), "%A")
 | rename latest_week as Today
 | rename 1week_before as [| stats count | eval tmp=strftime(now(), "%A") | eval str="\"Last ".tmp."\"" | return $str]

OR

earliest="-w@w" latest="+w@w" index="_internal" sourcetype="scheduler" 
     | timechart span=10m count 
     | timewrap w 
     | where strftime(_time,"%A") == strftime(now(), "%A") 
     | rename latest_week as Today
     | eval t=strftime(_time,"%A")
    | eval "Last {t}"='1week_before' | fields - 1week_before,t

View solution in original post

somesoni2
Revered Legend

There are multiple options

 earliest="-w@w" latest="+w@w" index="_internal" sourcetype="scheduler" 
 | timechart span=10m count 
 | timewrap w 
 | where strftime(_time,"%A") == strftime(now(), "%A")
 | rename latest_week as Today
 | rename 1week_before as [| stats count | eval tmp=strftime(now(), "%A") | eval str="\"Last ".tmp."\"" | return $str]

OR

earliest="-w@w" latest="+w@w" index="_internal" sourcetype="scheduler" 
     | timechart span=10m count 
     | timewrap w 
     | where strftime(_time,"%A") == strftime(now(), "%A") 
     | rename latest_week as Today
     | eval t=strftime(_time,"%A")
    | eval "Last {t}"='1week_before' | fields - 1week_before,t

p1stolero
Explorer

Both of your solutions worked perfectly, thank you!

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...