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!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Rounding off the Splunk Dashboard Contest

What does a contest-winning Splunk dashboard look like? In this case, it isn't in a browser tab at all. It ...

A Four Part Event Series: AI + Observability: AI Agents, LLMs, Apps, & Infrastructure

AI &#43; Observability: AI Agents, LLMs, Apps, & Infrastructure The rapid evolution of artificial intelligence ...