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!

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...

State of Splunk Careers 2024: Maximizing Career Outcomes and the Continued Value of ...

For the past four years, Splunk has partnered with Enterprise Strategy Group to conduct a survey that gauges ...

Data-Driven Success: Splunk & Financial Services

Splunk streamlines the process of extracting insights from large volumes of data. In this fast-paced world, ...