Getting Data In

How to discard extra text from a single line in events?

Kumar2
Loves-to-Learn Lots

Example: Mynameissachintendulkar .Except sachin I need to remove remaining all text .please help me with the query. Thanks in Advance

Labels (1)
0 Karma

Kumar2
Loves-to-Learn Lots

Eg: mynameisgautamkrishna .after extracting name=gautam .now I have to Delete everything Except Gautam and only name (Gautam) will display in events

.

.

.

mynameisgautamkrishna

After Ingest and Extract Name=Gautam

Gautam should display in Events as well as in corresponding Interesting field (Name)

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Kumar2,

you have to identify a rule to extract the field to display: e.g. take all after "mynameis".

In your sample, it's easy to understand where the field sarts but it's difficoult to understand where the field finishes:

| rex "mynameis(?<name>\w+)"

if the number of chars is fixed (e.g. 8), you could use something like this

| rex "mynameis(?<name>\w{8})"

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Kumar2,

what do you mean with "discard"?

are you speaking of discard before indexing or discard at search time?

If you're speaking of discard before indexing, see SEDCMD command, for more infos see at https://docs.splunk.com/Documentation/Splunk/latest/Data/Anonymizedata#Anonymize_data_with_a_sed_scr... 

Could you share some sample of your logs?

Ciao.

Giuseppe

0 Karma

Kumar2
Loves-to-Learn Lots

Discard at the Search time sir

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Kumar2,

if you have a rule for the not displaying part (e.g. all after Except), you could create a regex like this:

 

| rex "^(?<part_to_display>.*)Except"

 

to extract the part of _raw to display.

If you could share some sample I could help you more.

Ciao.

Giuseppe

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...