Splunk Search

how to get extract field in a numeric format?

gwtm_hak
Engager

I'm trying to extract value from a field in the raw text using a regular expression. I want the field values to be extracted in numeric format, but when I field extraction the value is in a string.

{"values":[17.4991095961511,17.4991095961511],"dstypes":["derive","derive"],"dsnames":["io_time","weighted_io_time"],"time":1565729243.743,"interval":2,"host":"node1-zanzibar","plugin":"disk","plugin_instance":"sda","type":"disk_io_time","type_instance":""}

I used the below expression,

^\{"(?P<values>\w+)

which captures the values field but not the values relative to that field.
So I tried with adding d+

^\{"(?P<values>\d+)

There was no result. can anyone help me solve this?

0 Karma
1 Solution

nareshinsvu
Builder

Can you try this?

|makeresults 
|eval _raw=" {\"values\":[17.4991095961511,17.4991095961511],\"dstypes\":[\"derive\",\"derive\"],\"dsnames\":[\"io_time\",\"weighted_io_time\"],\"time\":1565729243.743,\"interval\":2,\"host\":\"node1-zanzibar\",\"plugin\":\"disk\",\"plugin_instance\":\"sda\",\"type\":\"disk_io_time\",\"type_instance\":\"\"} " 

 | rex field=_raw "\{\"values\"\:\[(?<values>.*?)\s*\]\," max_match=0 
 | makemv delim="," values  
 | mvexpand values
 | table values

View solution in original post

nareshinsvu
Builder

Can you try this?

|makeresults 
|eval _raw=" {\"values\":[17.4991095961511,17.4991095961511],\"dstypes\":[\"derive\",\"derive\"],\"dsnames\":[\"io_time\",\"weighted_io_time\"],\"time\":1565729243.743,\"interval\":2,\"host\":\"node1-zanzibar\",\"plugin\":\"disk\",\"plugin_instance\":\"sda\",\"type\":\"disk_io_time\",\"type_instance\":\"\"} " 

 | rex field=_raw "\{\"values\"\:\[(?<values>.*?)\s*\]\," max_match=0 
 | makemv delim="," values  
 | mvexpand values
 | table values
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...