Splunk Search

How to extract these fields and compare the values?

marcroyer
New Member

Hi,

I have 2 fields. Field1 is named field13 and Field2 is named logical_usage.

Field1 contains "hard" : 1099511627776
Field2 contains "logical" : 664419

I tried to extract values after the : and after a ratio of the usage. That's for a quota ratio.

I tried with | rex, but I didn't find the right way to do it.

Thank you for your precious help.

0 Karma
1 Solution

sundareshr
Legend

This rex command will extract the number.

.... | rex field=field1 "\:\s*(?<field1value>\d+)" | rex field=field2 "\:\s*(?<field2value>\d+)" | table field1value field2value

View solution in original post

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Give this a try as well

your base search | eval Quota_Ratio=tonumber(mvindex(split(logical_usage," "),-1))/tonumber(mvindex(split(field13," "),-1))
0 Karma

sundareshr
Legend

This rex command will extract the number.

.... | rex field=field1 "\:\s*(?<field1value>\d+)" | rex field=field2 "\:\s*(?<field2value>\d+)" | table field1value field2value
0 Karma

marcroyer
New Member

Hi Guys,

Thank you very much !!! It's working as expected.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...