Dashboards & Visualizations

How to extract part of a field which has hyphens?

SGL
Engager

Hi,

I wanted to extract the field "login-first" and "delaccount" from result events. Following are 2 sample fields from the results logs.

cf_app_name: AB123-login-first-pr

cf_app_name: CD123-delaccount-pr

Sample query used :

index=preprod source=logmon env="preprod"

Please help me to extract the fields.

Thanks in advance,

SGL

Labels (1)
Tags (1)
0 Karma
1 Solution

Manasa_401
Communicator

Hello @SGL 

I hope the following regex helps you.

| rex field=cf_app_name "(?<new_field>(?<=-).*?(?=-pr))"

 

If this helps, an upvote would be appreciated.

Thanks,

Manasa

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @SGL,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma

Manasa_401
Communicator

Hello @SGL 

I hope the following regex helps you.

| rex field=cf_app_name "(?<new_field>(?<=-).*?(?=-pr))"

 

If this helps, an upvote would be appreciated.

Thanks,

Manasa

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @SGL,

to help you in field extraction is mandatory to have some sample of your logs to create a regex.

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Now Available: Cisco Talos Threat Intelligence Integrations for Splunk Security Cloud ...

At .conf24, we shared that we were in the process of integrating Cisco Talos threat intelligence into Splunk ...

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Easily Improve Agent Saturation with the Splunk Add-on for OpenTelemetry Collector

Agent Saturation What and Whys In application performance monitoring, saturation is defined as the total load ...