Splunk Search

rex command help...

harishalipaka
Motivator

Hi All,

my data is like below-- I want to extract when it has string ignore numbers

853727-gcplusrspcndb01.usa.corp.ad
10.198.29.5

Output:-

853727-gcplusrspcndb01
 10.198.29.5
Thanks
Harish
0 Karma

to4kawa
Ultra Champion
| rex mode=sed "s/[.a-z]*$//"
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @harishalipaka,
try this

| rex "^\s+(?<url>[^\.]+).*\s+(?<ip>\d+\.\d+\.\d+\.\d+)"

that you can test at https://regex101.com/r/6axOMx/1

Ciao.
Giuseppe

0 Karma

harishalipaka
Motivator

Hi @gcusello

It is not working for me .am getting empty fields.

| rex field=HostName "^\s+(?<url>[^\.]+).*\s+(?<ip>\d+\.\d+\.\d+\.\d+)"
Thanks
Harish
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @harishalipaka,
probably your row data are different, this regex is related to the information you shared, could you share an example of your row data?

Ciao.
Giuseppe

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Here's one way.

... | rex "(?<field>[^\.]+)"
---
If this reply helps you, Karma would be appreciated.
0 Karma

harishalipaka
Motivator

Hi @richgalloway

I already tried this logic but it will extract like below

853727-gcplusrspcndb01
10

But i want like this

853727-gcplusrspcndb01
  10.198.29.5
Thanks
Harish
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 ...