Splunk Search

How to split/extract substring before the first - from the right side of the string

keshavgupta
Engager
Spoiler
How to split/extract substring before the first - from the right side of the field on splunk search

For ex: My field hostname contains

Hostname = abc-xyz
Hostname = abc-01-def
Hostname = pqr-01

I want to see like below .

abc
abc-01
pqr

Please help me.

Labels (3)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<host>[^\-]+)\-"
0 Karma
Get Updates on the Splunk Community!

New This Month in Splunk Observability Cloud - Metrics Usage Analytics, Enhanced K8s ...

The latest enhancements across the Splunk Observability portfolio deliver greater flexibility, better data and ...

Alerting Best Practices: How to Create Good Detectors

At their best, detectors and the alerts they trigger notify teams when applications aren’t performing as ...

Discover Powerful New Features in Splunk Cloud Platform: Enhanced Analytics, ...

Hey Splunky people! We are excited to share the latest updates in Splunk Cloud Platform 9.3.2408. In this ...