<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Removing all white spaces from event at Index time in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345534#M63484</link>
    <description>&lt;P&gt;This should still work with strings of multiple characters.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2017 13:24:36 GMT</pubDate>
    <dc:creator>cpetterborg</dc:creator>
    <dc:date>2017-09-22T13:24:36Z</dc:date>
    <item>
      <title>Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345525#M63475</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;

&lt;P&gt;I want to remove the whitespaces from only the account value, and not the whole event at index time. Is this possible?&lt;/P&gt;

&lt;P&gt;Given the events look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"account": "Account", "justification": "TEST 1", "value": "50"}

{"account": "dev 1", "justification": "TEST 2", "value": "50"}

{"account": "uat test acc", "justification": "TEST 3", "value": "50"}

{"account": "a .. x .. y .. z .. etc", "justification": "TEST 4", "value": "50"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want it to look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"account": "Account", "justification": "TEST 1", "value": "50"}

{"account": "dev1", "justification": "TEST 2", "value": "50"}

{"account": "uattestacc", "justification": "TEST 3", "value": "50"}

{"account": "axyzetc", "justification": "TEST 4", "value": "50"}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2017 15:50:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345525#M63475</guid>
      <dc:creator>Tim_1</dc:creator>
      <dc:date>2017-09-21T15:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345526#M63476</link>
      <description>&lt;P&gt;try this,&lt;/P&gt;

&lt;P&gt;| makeresults | eval test="{\"account\": \"Account 1 2\", \"justification\": \"TEST 1\", \"value\": \"50\"}" | rex field=test "(?P&amp;lt;t1&amp;gt;{\"account\":\s+)(?P&amp;lt;t2&amp;gt;\"Account\s+\S+.*\")(?P&amp;lt;t3&amp;gt;\,\s+\"justification\":\s+\"TEST\s+\d+\"\,\s+\"value\":\s+\"\d+\"})" | rex field=t2 mode=sed "s/ //g" | eval t4=t1+t2 | eval t5=t4+t3 | rename t5 as test&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 18:01:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345526#M63476</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-09-21T18:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345527#M63477</link>
      <description>&lt;P&gt;The following is assuming that you really have data that looks like &lt;CODE&gt;1 .. n&lt;/CODE&gt; in your data stream, rather than something like &lt;CODE&gt;1 2 3 4 5 6 7 8 9 0&lt;/CODE&gt;. If you have only things like the latter, then it will be a simpler regex, but this one will work either way.&lt;/P&gt;

&lt;P&gt;You could probably do something like this in &lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-pass1 = s/Account ([^"\s]+)(\s([^"\s]+))?(\s([^"\s]+))?(\s([^"\s]+))?(\s([^"\s]+))?/\1\2\4\6\8/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will remove up to 4 spaces. If you need to do more, then add a second pass, or third pass:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-pass2 = s/Account ([^"\s]+)(\s([^"\s]+))?(\s([^"\s]+))?(\s([^"\s]+))?(\s([^"\s]+))?/\1\2\4\6\8/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I haven't completely tested this, but I believe it to be fairly correct. If your event data differs much from this example, then it could make things more difficult.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 18:12:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345527#M63477</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-09-21T18:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345528#M63478</link>
      <description>&lt;P&gt;I assume that you mean you want to eliminate all spaces, or all white space, from the account field at index time? &lt;/P&gt;

&lt;P&gt;Try something like this in transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[stanzaname]
SOURCE_KEY = account
REGEX = ^([^\s]+)(\s+)*([^\s]*)(\s+)*([^\s]*)(\s+)*([^\s]*)(\s+)*([^\s]*)(\s+)*(.*)$
DEST_KEY = account
FORMAT = $1$3$5$7$9$11
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can repeat this phrase &lt;CODE&gt;([^\s]*)(\s+)*&lt;/CODE&gt; once for each number of spaces you want to eliminate, and add one more odd number to the FORMAT.  Not sure how many is the highest possible number.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 18:13:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345528#M63478</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-21T18:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345529#M63479</link>
      <description>&lt;P&gt;Hey @Tim_1 if they solved your problem, please don't forget to accept an answer! You can upvote posts as well. (Karma points will be awarded for either action.) Happy Splunking!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 00:13:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345529#M63479</guid>
      <dc:creator>lfedak_splunk</dc:creator>
      <dc:date>2017-09-22T00:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345530#M63480</link>
      <description>&lt;P&gt;Hi @sbbadri, &lt;/P&gt;

&lt;P&gt;Thanks for the answer, but I am looking at doing this at index time and not at search time.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 09:03:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345530#M63480</guid>
      <dc:creator>Tim_1</dc:creator>
      <dc:date>2017-09-22T09:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345531#M63481</link>
      <description>&lt;P&gt;Hi @DalJeanis, &lt;/P&gt;

&lt;P&gt;Thanks for the answer. Is there a way to do it without having to change it depending on the number of spaces? I would prefer not to have to create multiple stanza for each different number of n spaces.&lt;/P&gt;

&lt;P&gt;Also, my question wasn't 100% clear on the data I want to reformat. I've updated the question to be more inline of what the data should be.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 09:08:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345531#M63481</guid>
      <dc:creator>Tim_1</dc:creator>
      <dc:date>2017-09-22T09:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345532#M63482</link>
      <description>&lt;P&gt;Hi @cpetterborg,&lt;/P&gt;

&lt;P&gt;Thanks for the answer. My question wasn't 100% clear with the examples, so I've updated the question to be more inline of what the data should be.&lt;/P&gt;

&lt;P&gt;The data won't be integers, but strings.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 09:13:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345532#M63482</guid>
      <dc:creator>Tim_1</dc:creator>
      <dc:date>2017-09-22T09:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345533#M63483</link>
      <description>&lt;P&gt;Hi @Ifedak, will do so once I found a solution. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 09:13:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345533#M63483</guid>
      <dc:creator>Tim_1</dc:creator>
      <dc:date>2017-09-22T09:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345534#M63484</link>
      <description>&lt;P&gt;This should still work with strings of multiple characters.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 13:24:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345534#M63484</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-09-22T13:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Removing all white spaces from event at Index time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345535#M63485</link>
      <description>&lt;P&gt;Yes, got it half working so far.&lt;BR /&gt;
Thanks for the help. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
Will accept when fully complete. &lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 13:27:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Removing-all-white-spaces-from-event-at-Index-time/m-p/345535#M63485</guid>
      <dc:creator>Tim_1</dc:creator>
      <dc:date>2017-09-22T13:27:02Z</dc:date>
    </item>
  </channel>
</rss>

