Splunk Search

How to multiply?

rlaul
Engager

Hi,

Can someone please help me with this query? I am trying to multiply the fields Batch_Size and count and return the results in the tc field. I tried the above syntax but it did not work.

The first three lines of this query work fine by itself. After adding the lines 4,5, it does not return anything.

"\(TOTAL_REC\)::"
|rex field=_raw "(\(TOTAL_REC\)::)(?P\s(\d))"
|stats count  by Batch_Size
| eval tc = Batch_Size*count
| stats sum(tc) as tc

Any help will be appreciated.

Thanks, Ro,

Tags (1)
0 Karma

mayurr98
Super Champion

could you pls post the output of first 3 lines?

0 Karma

jpolvino
Builder

When you do a stats command (line 3), the fields visible before it become inaccessible. One way to solve your question:

"\(TOTAL_REC\)::"
|rex field=_raw "(\(TOTAL_REC\)::)(?P\s(\d))"
|stats count  AS Volume BY Batch_Size
| eval tc = Batch_Size*Volume

This creates a new field, but you need a field name (Volume) in your stats command for it to work.

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 ...