Splunk Search

How to write a search to create a column that will produce results based on another column's data?

payal23
Path Finder
Column1    Column2
28         28
46         46-28
58         58-(28+46)
89         89-(28+46+58)

Is this possible? If yes, plz suggest how to write a search for this.

Thanks,
Payal

0 Karma

aholzer
Motivator

This should do what you need:

... | streamstats sum(column1) AS cum_total | eval cum_total = cum_total - column1| eval column2 = column1 - cum_total | fields - cum_total

Explanation:

  • streamstats sum(column1) AS cum_total = will calculate the cumulative total including the value of column1
  • eval cum_total = cum_total - column1 = removes the value of column1 from the cum_total
  • eval column2 = column1 - cum_total = calculates the value of column2 for you
  • fields - cum_total = removes the cum_total column from your results

Hope this helps

--- EDIT ---

Just had another thought. You might be able to solve this with the delta command. Go here for details.

0 Karma

piUek
Path Finder
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...