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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...