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!

Enterprise Security Content Update (ESCU) | New Releases

In January, the Splunk Threat Research Team had one release of new security content via the Splunk ES Content ...

Expert Tips from Splunk Professional Services, Ensuring Compliance, and More New ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Observability Release Update: AI Assistant, AppD + Observability Cloud Integrations & ...

This month’s releases across the Splunk Observability portfolio deliver earlier detection and faster ...