Splunk Search

regex help

gitingua
Communicator

hello my friends. 

how using regex can delete everything in bold

 

{"test": "  {   \n \"data\": \"check\",\n \"git_branch\": \"master\",\n \"git_repo_name\": \"reponame\",\n \"id\": 234,\n \"timestamp\": 16378522342,\n"}

 

output

 { \"data\": \"check\"\"git_branch\": \"master\", \"git_repo_name\": \"reponame\", \"id\": 3413, \"timestamp\": 16378522342 }

0 Karma

Gr0und_Z3r0
Contributor

Hi @gitingua , if you want a clean JSON data, then you can try something like this...

| makeresults 
| eval jsonData ="{\"test\": \"  {   \\n \\\"data\\\": \\\"check\\\",\\n \\\"git_branch\\\": \\\"master\\\",\\n \\\"git_repo_name\\\": \\\"reponame\\\",\\n \\\"id\\\": 234,\\n \\\"timestamp\\\": 16378522342,\\n } \"}"
| spath input=jsonData path=test output=result

Gr0und_Z3r0_0-1638075234209.png

 

Please vote up if it helps!

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Does something like this work?

| rex mode=sed "s/\\n//g"
| rex mode=sed "s/\{\"test\":\s*\"\s*//g"
| rex mode=sed "s/\s*\"\}//g"
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...