Splunk Search

Dynamically generating a Field Name for a Table

tschmoney1337
New Member

Hi everyone!

I'm trying to figure out how to map a field name dynamically to a column of a table. as it stands the table looks like this:

twomonth_valueonemonth_valuecurrent_value
531

 

I want the output to be instead..

july_valueaugust_valueseptember_value
531

 

I am able to get the correct dynamic value of each month via

| eval current_value = strftime(relative_time(now(), "@mon"), "%B")+."_value"

However, i'm unsure on how to change the field name directly in the table.

Thanks in advance!

Labels (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @tschmoney1337 ,

please share your full search because you can modify the field name in rows but not in columns.

e.g. if you have a timestamp, you should use stats and eval, and then put in columns:

<your_search>
| bin span=1mon _time
| stats count BY _time
| eval current_value = strftime(_time, "%B")."_value"
| table current_value count
| transpose column_name=current_value header_field=current_value

I cannopt test it , but it should be correct or very near.

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Index This | What did the zero say to the eight?

June 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

Splunk Observability Cloud's AI Assistant in Action Series: Onboarding New Hires & ...

This is the fifth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Now Playing: Splunk Education Summer Learning Premieres

It’s premiere season, and Splunk Education is rolling out new releases you won’t want to miss. Whether you’re ...