Splunk Search

How to extract a numeric field with rex, then run a timechart with the max value over 5 minutes?

sheltomt
Path Finder

Hello,

I'm trying to extract a field, and then run a timechart with the max value over 5 minutes.

My extraction is strictly the tail integer of this string:

<server2name-loc-l1p.domain.com@10.10.10.10#sessions=568>

Best looking solution I found so far is:

| rex field=_raw ".*#sessions +(?<number>[0-9]+)" |timechart span="5m" max(number)

But it does nothing.

0 Karma
1 Solution

sheltomt
Path Finder

We solved it by going a whole different direction. I was fooling with a super long string, but my co-worker came up with:

rex ".*=(?P\d+)\D"

We're good!

View solution in original post

santiagoaloi
Path Finder

You can even use a shorter one:

| rex field=_raw ".*=(?\d+)"

alt text

0 Karma

sheltomt
Path Finder

We solved it by going a whole different direction. I was fooling with a super long string, but my co-worker came up with:

rex ".*=(?P\d+)\D"

We're good!

aljohnson_splun
Splunk Employee
Splunk Employee

What happens if you table out the number values first ? Is your extraction working?

| rex field=_raw ".*#sessions +(?<number>[0-9]+)"
| table number
0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...