Splunk Search

Not adding up

bbhandari012
Explorer

sourcetype=splunklog metric="memory"|rex field=_raw "(?i)memory-used\s+(?P\d+)" |rex field=_raw "(?i)memory-buffered\s+(?P\d+)" |rex "(?i)memory-cached\s+(?P\d+)"|rex "(?i)memory-slab_unrecl\s+(?P\d+)"|rex "(?i)memory-slab_recl\s+(?P\d+)"| eval sum=(val+val1+val2+val3+val4) | table sum val1 val2 val3

its not adding the value, but shows the individual value fine. Can one one please help me ??

Tags (1)
0 Karma

somesoni2
Revered Legend

It looks like not all the val are getting populated for each events (could be null). Try this

sourcetype=splunklog metric="memory"|rex field=_raw "(?i)memory-used\s+(?P<val>\d+)" |rex field=_raw "(?i)memory-buffered\s+(?P<val1>\d+)" |rex "(?i)memory-cached\s+(?P<val2>\d+)"|rex "(?i)memory-slab_unrecl\s+(?P<val3>\d+)"|rex "(?i)memory-slab_recl\s+(?P<val4>\d+)" | fillnull value=0 val* | eval sum=(val+val1+val2+val3+val4) | table sum val1 val2 val3

OR

sourcetype=splunklog metric="memory"|rex field=_raw "(?i)memory-used\s+(?P<val>\d+)" |rex field=_raw "(?i)memory-buffered\s+(?P<val1>\d+)" |rex "(?i)memory-cached\s+(?P<val2>\d+)"|rex "(?i)memory-slab_unrecl\s+(?P<val3>\d+)"|rex "(?i)memory-slab_recl\s+(?P<val4>\d+)" | eval sum=(coalesce(val,0)+coalesce(val1,0)+coalesce(val2,0)+coalesce(val3,0)+coalesce(val4,0)) | table sum val1 val2 val3
0 Karma
Get Updates on the Splunk Community!

AI for AppInspect

We’re excited to announce two new updates to AppInspect designed to save you time and make the app approval ...

App Platform's 2025 Year in Review: A Year of Innovation, Growth, and Community

As we step into 2026, it’s the perfect moment to reflect on what an extraordinary year 2025 was for the Splunk ...

Operationalizing Entity Risk Score with Enterprise Security 8.3+

Overview Enterprise Security 8.3 introduces a powerful new feature called “Entity Risk Scoring” (ERS) for ...