Splunk Search

How to include month name in streamstats as?

dvg06
Path Finder

Hi Legends

How do I give bit more meaningful names for fields last_sum and first_sum in below query?

i.e. something like sum_February and sum_March? 

Is there a way to use the value of date_month field in a search? 

streamstats current=f window=1 last(sum) as last_sum  first(sum) as first_sum

Labels (1)

yeahnah
Motivator

Hi @dvg06 

Assuming you want something dynamic, then this run anywhere example shows a method to use...

| makeresults | eval last_sum="100", first_sum="200"
| eval current_month=strftime(now(), "%B"), previous_month=strftime(relative_time(now(), "-1month@month"), "%B")
      ,last_{current_month}=last_sum, first_{previous_month}=first_sum
| table last* first*

Hope that helps

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!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...