<?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: How to form splunk query to split a field and make separate fields as per the maximum number of partitions? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-splunk-query-to-split-a-field-and-make-separate/m-p/483507#M135355</link>
    <description>&lt;P&gt;I couldn't come up with a generic way to put each OU in a separate field.  I think I have a decent equivalent, however.   It shows the unique sets of OUs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xx sourcetype=yy
| fields s
| rex field=s max_match=0 "OU=(?&amp;lt;OU&amp;gt;[^,]+)"
| eval OUs=mvjoin(OU, ",")
| dedup OUs
| table OUs
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Apr 2020 18:19:38 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-04-27T18:19:38Z</dc:date>
    <item>
      <title>How to form splunk query to split a field and make separate fields as per the maximum number of partitions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-splunk-query-to-split-a-field-and-make-separate/m-p/483506#M135354</link>
      <description>&lt;P&gt;I have some strings like below returned by my splunk base search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"CN=aa,OU=bb,DC=cc,DC=dd,DC=ee"
"CN=xx,OU=bb,DC=cc,DC=yy,DC=zz"
"CN=ff,OU=gg,OU=hh,DC=ii,DC=jj"
"CN=kk,DC=ll,DC=mm"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: CN,OU,DC could be 0 or many.&lt;/P&gt;

&lt;P&gt;My ultimate goal is to find all OUs something like below.&lt;BR /&gt;&lt;BR /&gt;
(The combinations also need to be unique.)&lt;BR /&gt;&lt;BR /&gt;
(All blank lines can be excluded.)&lt;BR /&gt;&lt;BR /&gt;
eg:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;bb     (blank)
gg      hh
(blank) (blank)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The query that am using currently is very naive.&lt;BR /&gt;&lt;BR /&gt;
Plus it is not generic.&lt;BR /&gt;&lt;BR /&gt;
It will work if atleast one of my split results into 5 parts (0,1,2,3,4).&lt;BR /&gt;&lt;BR /&gt;
But, it will not work and give blank results if none of my split results into 5 parts (0,1,2,3,4)   i.e. all of them result in less than 5 parts.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xx sourcetype=yy
| fields s
| rex field=s mode=sed "s/,DC=.*//g"
| eval temp=split(s,",OU=")
| eval a=mvindex(temp,1)
| eval b=mvindex(temp,2)
| eval c=mvindex(temp,3)
| eval d=mvindex(temp,4)
| dedup a b c d
| table a,b,c,d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How to make it generic i.e. get the count of split and make fields as per maximum split length?  &lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 17:17:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-splunk-query-to-split-a-field-and-make-separate/m-p/483506#M135354</guid>
      <dc:creator>smitapatankarso</dc:creator>
      <dc:date>2020-04-27T17:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to form splunk query to split a field and make separate fields as per the maximum number of partitions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-splunk-query-to-split-a-field-and-make-separate/m-p/483507#M135355</link>
      <description>&lt;P&gt;I couldn't come up with a generic way to put each OU in a separate field.  I think I have a decent equivalent, however.   It shows the unique sets of OUs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xx sourcetype=yy
| fields s
| rex field=s max_match=0 "OU=(?&amp;lt;OU&amp;gt;[^,]+)"
| eval OUs=mvjoin(OU, ",")
| dedup OUs
| table OUs
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Apr 2020 18:19:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-splunk-query-to-split-a-field-and-make-separate/m-p/483507#M135355</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-04-27T18:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to form splunk query to split a field and make separate fields as per the maximum number of partitions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-splunk-query-to-split-a-field-and-make-separate/m-p/483508#M135356</link>
      <description>&lt;P&gt;saved my effort of further processing as well.  &lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 19:18:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-splunk-query-to-split-a-field-and-make-separate/m-p/483508#M135356</guid>
      <dc:creator>smitapatankarso</dc:creator>
      <dc:date>2020-04-27T19:18:59Z</dc:date>
    </item>
  </channel>
</rss>

