Getting Data In

How to remove part of the string using rex

aaa2324
Explorer

I have the below string and would like to remove the date and time part, please help with the query

*abc -04/30, 08:14:07 - c

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval _raw="abc -04/30, 08:14:07 - c"
| rex mode=sed "s/\-\d\d\/\d\d,\s\d\d:\d\d:\d\d\s/- /g"
0 Karma

aaa2324
Explorer

Thanks  however not getting the desired results, if the date and time are dynamic and keeps changing then please help with the complete query. I want to remove the date and time completely and show the results 

abc -04/30, 08:14:07 - c

abc -04/28, 08:15:06 - c

abc -04/29, 08:12:09 - a

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Please explain how the suggested rex does not do as you expected. It might be clearer if you provide some real anonymised events with which to work with.

0 Karma

aaa2324
Explorer

Sorry if the question was not clear.

my intention is to remove date and time fields from the below set of input.

let’s say the column xyz has below contents

abc -04/30, 08:14:07 - c

abc -04/28, 08:15:06 - c

abc -04/29, 08:12:09 - a

my result should be something like below only remove the date and time and display rest of the fields 

abc - - c

abc - - c

abc - - a

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval xyz="abc -04/30, 08:14:07 - c
abc -04/28, 08:15:06 - c
abc -04/29, 08:12:09 - a"
| rex field=xyz max_match=0 "(?<xyz>.*)\n*"
| mvexpand xyz
| rex mode=sed field=xyz "s/\-\d\d\/\d\d,\s\d\d:\d\d:\d\d\s/- /g"
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...