Refine your search:

Hi,

I have a field called operationDuration. This field has a value in the form of Xms. Eg:10ms How can I parse this value so that I remove the ms, i.e. I get only the numerical value? I tried to do this in the Tag extraction, but regex look around does not seem to work.

Thanks a lot

Simon

asked 03 Feb '12, 06:55

simonattardGO's gravatar image

simonattardGO
915
accept rate: 0%


2 Answers:

Have your tried this (assuming that the field operationDuration is already extracted);

  your_search | rex field=operationDuration "(?<OPER_DUR_NUM>\d+)ms"

The extraction above will give you a field called OPER_DUR_NUM in the fields column on the left. You can of course call it whatever you like.


UPDATE:

In order to test whether the extraction worked correctly, you can type in the following search:

 your_search | rex field=operationDuration "(?<OPER_DUR_NUM>\d+)ms" | table operationDuration, OPER_DUR_NUM

Also, note that this is not a "permanent" field extraction - it only lives within this search. If you want to make the new field available without specifying the rex statement as part of every search query, you should make a permanent extraction, e.g. with IFX or directly in props.conf.

For more info on field extraction see:

http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Addfieldsatsearchtime

/Kristian

link

answered 03 Feb '12, 07:08

kristian.kolb's gravatar image

kristian.kolb
10.0k615
accept rate: 33%

edited 06 Feb '12, 03:01

thanks for your post kristian.

How can I view the extracted value, so that I can check if the extraction was correct?

Thanks

(06 Feb '12, 02:27) simonattardGO

you could use:

| convert num(operationDuration)

http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/convert

link

answered 03 Feb '12, 07:08

imrago's gravatar image

imrago
8481416
accept rate: 40%

Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×459

Asked: 03 Feb '12, 06:55

Seen: 925 times

Last updated: 06 Feb '12, 03:01

Copyright © 2005-2012 Splunk Inc. All rights reserved.