Splunk Search

How to write a search to append a header variable to all events from the same source?

moaf13
Path Finder

I have a header variable that I would like to attach to each event in a table.

Header variable, FY= 2017

table

bill | reason | FY
100 |restaurant | 2017
200 | gas | 2017
500 | water | 2017

\sourcetype=Bill |table bill reason|appendcols[search sourtype=Bill |fields FY]  |table bill reason FY

The search above does not append the column to all events, it only appends it to the first row.
Is there a search or function that allows me to append the variable to all the events.

FYI, when I do eval tempVari="test", it attaches it to all events, but it doesn't work when it's a variable.

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try this

sourcetype=Bill |table bill reason|appendcols[search sourtype=Bill |fields FY] | filldown FY | table bill reason FY
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Try this

sourcetype=Bill |table bill reason|appendcols[search sourtype=Bill |fields FY] | filldown FY | table bill reason FY
---
If this reply helps you, Karma would be appreciated.

moaf13
Path Finder

Thank you, that was exactly what i was looking for!

0 Karma

niketn
Legend

I am not sure whether I get your question right. But seems like you should look for eventstats command which appends a field to events returned by search. Refer to documentation below:

http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Eventstats

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

moaf13
Path Finder

i'm just trying to attach the variable that contains the year 2017 to all events. I'm not doing any calculation. the variable exist only in file header meaning it will only be in one event.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...