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!

Enterprise Security Content Update (ESCU) | New Releases

In January, the Splunk Threat Research Team had one release of new security content via the Splunk ES Content ...

Expert Tips from Splunk Professional Services, Ensuring Compliance, and More New ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Observability Release Update: AI Assistant, AppD + Observability Cloud Integrations & ...

This month’s releases across the Splunk Observability portfolio deliver earlier detection and faster ...