Splunk Search

use rex to extract last word/number in a line

sriva6
New Member

Hi,

I have logs like theses:

blah blah (Linux+amd64+2.6.18-308.11.1.el5;+Java+HotSpot(TM)+64-Bit+Server+VM+20.5-b03) 200 0 0 8
blah blah (Linux+amd64+2.6.18-308.11.1.el5;+Java+HotSpot(TM)+64-Bit+Server+VM+20.5-b03) 401 2 5 1

I want to extract the last number(s) from the logs. in the above examples I want 8 and 1. How can I do this using rex?

Tags (1)
0 Karma

lsnow
Explorer

This should work if the last field is always numeric - otherwise change the '\d' as appropriate.

| rex "(?<lastfield>\d+$)

hartfoml
Motivator

Ayn, the answer above didn't work for my

I have multiple line log entry and the last line reads like this
[Message=Product: Epicor Administration Console -- Removal completed successfully.]

I want to get the work Successfully without the period.

0 Karma

ppuru
Path Finder

Thank you. This really helped.

0 Karma
Get Updates on the Splunk Community!

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 ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...