Getting Data In

sed combined help

mcbradford
Contributor

I am using the following to clean up output:

rex mode=sed field=search_google2 "s/\%20/ /g";"s/\%5B/[/g" | rex mode=sed field=search_google2 "s/\%22/\"/g" | rex mode=sed field=search_google2 "s/\%5B/[/g" | rex mode=sed field=search_google2 "s/\%5D/]/g" | rex mode=sed field=search_google2 "s/\%2B/+/g" | rex mode=sed field=search_google2 "s/\%2C/,/g" | rex mode=sed field=search_google2 "s/\%3A/:/g" | rex mode=sed field=search_google2 "s/\%27/'/g" | rex mode=sed field=search_google2 "s/\%40/@/g" | rex mode=sed field=search_google2 "s/\%3B/;/g" | rex mode=sed field=search_google2 "s/\%25/%/g"

I am new to regex.... can I combine the regex into one statement instead of the multiple pipes?

Tags (1)
0 Karma

kristian_kolb
Ultra Champion

Well, sed supports the y command (character substitution), but since there is not a 1-to-1 mapping, I don't think you can apply that here.

http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex
http://docs.splunk.com/Documentation/Splunk/5.0.2/Data/Anonymizedatausingconfigurationfiles#Through_...

However, you can put all of your regexes into props.conf SEDCMD statements, or through transforms, which would make the alteration permanent (may not be compatible with any requirements of keeping data in its original format, if you have such).

http://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf
http://docs.splunk.com/Documentation/Splunk/5.0.2/Data/Anonymizedatausingconfigurationfiles#Through_...

Hope this helps,

Kristian

Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...