<?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: Creating a custom SourceType with multiple delimiters (35 fields) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493050#M194364</link>
    <description>&lt;P&gt;hi @gcusello &lt;/P&gt;

&lt;P&gt;Thank you so much for pointing me in the direction of regex, I've never played in that area before.&lt;/P&gt;

&lt;P&gt;Using regex101.com with some placeholder values and I've got it working there I just need to get it conforming to splunks syntax now.&lt;/P&gt;

&lt;P&gt;This is what I have so far:&lt;/P&gt;

&lt;P&gt;Date,Time,Activity:Info:ComputerName|Country|City&lt;BR /&gt;
2019-11-19,00:00:00,Browsing:Google:PC01|Australia|Brisbane&lt;BR /&gt;
2019-11-19,00:30:00,Browsing:YouTube:PC02|Australia|Sydney&lt;/P&gt;

&lt;P&gt;and the regex I use is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;field1&amp;gt;[^\,]*)(,)(?&amp;lt;field2&amp;gt;[^\,]*)(,)(?&amp;lt;field3&amp;gt;[^\:]*)(:)(?&amp;lt;field4&amp;gt;[^\:]*)(:)(?&amp;lt;field5&amp;gt;[^\|]*)(\|)(?&amp;lt;field6&amp;gt;[^\|]*)(\|)(?&amp;lt;field7&amp;gt;[^\n]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm sure there's a way to say:&lt;BR /&gt;
use commas for the first 8 fields, colons for the next 2 and pipes for the final 25 and somehow add the field names in before hand but at this stage I'm probably just going to define all 35 fields once I figure out how to make Splunk recognise these 7 &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Nov 2019 08:36:31 GMT</pubDate>
    <dc:creator>whitehaven</dc:creator>
    <dc:date>2019-11-26T08:36:31Z</dc:date>
    <item>
      <title>Creating a custom SourceType with multiple delimiters (35 fields)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493048#M194362</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I've searched around a bit and I can't seem to find the answer after failing to figure it out myself.&lt;/P&gt;

&lt;P&gt;The data I've got has multiple delimiters and I somehow got it to recognise two of them but not the third.&lt;/P&gt;

&lt;P&gt;Hopefully this makes sense but I have 35 fields that I want to delimiter like this:&lt;BR /&gt;
,,,,,,,::|||||||||||||||||||||||||&lt;/P&gt;

&lt;P&gt;So basically the first 8 fields should be delimited by commas the next 2 fields by colons and the remaining 25 by pipes.&lt;/P&gt;

&lt;P&gt;Has anyone had experience or success with this?&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 06:57:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493048#M194362</guid>
      <dc:creator>whitehaven</dc:creator>
      <dc:date>2019-11-25T06:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom SourceType with multiple delimiters (35 fields)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493049#M194363</link>
      <description>&lt;P&gt;Hi @whitehaven,&lt;BR /&gt;
I never found a situation like this!&lt;BR /&gt;
Anyway you can use a regex to extract fields&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;field1&amp;gt;[^\|,:]*)(\||,|:)(?&amp;lt;field2&amp;gt;[^\|,:]*)(\||,|:)(?&amp;lt;field3&amp;gt;[^\|,:]*)(\||,|:)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or if the number of delimers of each kind is fixed (one in my example)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;field1&amp;gt;[^,]*),(?&amp;lt;field2&amp;gt;[^:]*):(?&amp;lt;field3&amp;gt;[^\|]*)\|
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 08:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493049#M194363</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-25T08:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom SourceType with multiple delimiters (35 fields)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493050#M194364</link>
      <description>&lt;P&gt;hi @gcusello &lt;/P&gt;

&lt;P&gt;Thank you so much for pointing me in the direction of regex, I've never played in that area before.&lt;/P&gt;

&lt;P&gt;Using regex101.com with some placeholder values and I've got it working there I just need to get it conforming to splunks syntax now.&lt;/P&gt;

&lt;P&gt;This is what I have so far:&lt;/P&gt;

&lt;P&gt;Date,Time,Activity:Info:ComputerName|Country|City&lt;BR /&gt;
2019-11-19,00:00:00,Browsing:Google:PC01|Australia|Brisbane&lt;BR /&gt;
2019-11-19,00:30:00,Browsing:YouTube:PC02|Australia|Sydney&lt;/P&gt;

&lt;P&gt;and the regex I use is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;field1&amp;gt;[^\,]*)(,)(?&amp;lt;field2&amp;gt;[^\,]*)(,)(?&amp;lt;field3&amp;gt;[^\:]*)(:)(?&amp;lt;field4&amp;gt;[^\:]*)(:)(?&amp;lt;field5&amp;gt;[^\|]*)(\|)(?&amp;lt;field6&amp;gt;[^\|]*)(\|)(?&amp;lt;field7&amp;gt;[^\n]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm sure there's a way to say:&lt;BR /&gt;
use commas for the first 8 fields, colons for the next 2 and pipes for the final 25 and somehow add the field names in before hand but at this stage I'm probably just going to define all 35 fields once I figure out how to make Splunk recognise these 7 &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 08:36:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493050#M194364</guid>
      <dc:creator>whitehaven</dc:creator>
      <dc:date>2019-11-26T08:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom SourceType with multiple delimiters (35 fields)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493051#M194365</link>
      <description>&lt;P&gt;Hi @whitehaven,&lt;BR /&gt;
ok!&lt;BR /&gt;
only one little update: pipe (|) is a special char and need to be escaped, comma (,) and colon (:) don't need.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 08:58:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493051#M194365</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-26T08:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom SourceType with multiple delimiters (35 fields)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493052#M194366</link>
      <description>&lt;P&gt;I've also had success using your second example this way&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;field1&amp;gt;[^,]*),(?&amp;lt;field2&amp;gt;[^,]*),(?&amp;lt;field3&amp;gt;[^\:]*):(?&amp;lt;field4&amp;gt;[^\:]*):(?&amp;lt;field5&amp;gt;[^\|]*)\|(?&amp;lt;field6&amp;gt;[^\|]*)\|(?&amp;lt;field7&amp;gt;[^\n]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Again, still trying to sort the syntax for Splunk &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 09:10:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493052#M194366</guid>
      <dc:creator>whitehaven</dc:creator>
      <dc:date>2019-11-26T09:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom SourceType with multiple delimiters (35 fields)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493053#M194367</link>
      <description>&lt;P&gt;Hi @whitehaven,&lt;BR /&gt;
sorry, but I don't understand: what do you mean with "to sort the syntax for Splunk"&lt;BR /&gt;
do you mean to use this regex in Splunk searches?&lt;/P&gt;

&lt;P&gt;If this is you problem, you can use this regex using the rex command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_search
| rex "(?&amp;lt;field1&amp;gt;[^,]*),(?&amp;lt;field2&amp;gt;[^,]*),(?&amp;lt;field3&amp;gt;[^\:]*):(?&amp;lt;field4&amp;gt;[^\:]*):(?&amp;lt;field5&amp;gt;[^\|]*)\|(?&amp;lt;field6&amp;gt;[^\|]*)\|(?&amp;lt;field7&amp;gt;[^\n]*)"
| ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or creating a new fiels and inserting in it this regex.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 10:13:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493053#M194367</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-26T10:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom SourceType with multiple delimiters (35 fields)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493054#M194368</link>
      <description>&lt;P&gt;Mate, you're awesome&lt;/P&gt;

&lt;P&gt;I did want to create a SourceType for this instead of doing an inline search because with 35 fields it looks disgusting but... It will work for now, so I've added this to the end of the search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "(?&amp;lt;field1&amp;gt;[^,]*),(?&amp;lt;field2&amp;gt;[^,]*),(?&amp;lt;field3&amp;gt;[^,]*),(?&amp;lt;field4&amp;gt;[^,]*),(?&amp;lt;field5&amp;gt;[^,]*),(?&amp;lt;field6&amp;gt;[^,]*),(?&amp;lt;field7&amp;gt;[^,]*),(?&amp;lt;field8&amp;gt;[^:]*):(?&amp;lt;field9&amp;gt;[^:]*):(?&amp;lt;field10&amp;gt;[^\|]*)\|(?&amp;lt;field11&amp;gt;[^\|]*)\|(?&amp;lt;field12&amp;gt;[^\|]*)\|(?&amp;lt;field13&amp;gt;[^\|]*)\|(?&amp;lt;field14&amp;gt;[^\|]*)\|(?&amp;lt;field15&amp;gt;[^\|]*)\|(?&amp;lt;field16&amp;gt;[^\|]*)\|(?&amp;lt;field17&amp;gt;[^\|]*)\|(?&amp;lt;field18&amp;gt;[^\|]*)\|(?&amp;lt;field19&amp;gt;[^\|]*)\|(?&amp;lt;field20&amp;gt;[^\|]*)\|(?&amp;lt;field21&amp;gt;[^\|]*)\|(?&amp;lt;field22&amp;gt;[^\|]*)\|(?&amp;lt;field23&amp;gt;[^\|]*)\|(?&amp;lt;field24&amp;gt;[^\|]*)\|(?&amp;lt;field25&amp;gt;[^\|]*)\|(?&amp;lt;field26&amp;gt;[^\|]*)\|(?&amp;lt;field27&amp;gt;[^\|]*)\|(?&amp;lt;field28&amp;gt;[^\|]*)\|(?&amp;lt;field29&amp;gt;[^\|]*)\|(?&amp;lt;field30&amp;gt;[^\|]*)\|(?&amp;lt;field31&amp;gt;[^\|]*)\|(?&amp;lt;field32&amp;gt;[^\|]*)\|(?&amp;lt;field33&amp;gt;[^\|]*)\|(?&amp;lt;field34&amp;gt;[^\|]*)\|(?&amp;lt;field35&amp;gt;[^\|]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you think it's viable to try and get that info into the SourceType so it is already formatted like this? I've had no luck trying but the search does work.&lt;/P&gt;

&lt;P&gt;Thanks so much for your help @gcusello &lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 00:29:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493054#M194368</guid>
      <dc:creator>whitehaven</dc:creator>
      <dc:date>2019-11-27T00:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom SourceType with multiple delimiters (35 fields)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493055#M194369</link>
      <description>&lt;P&gt;Hi @whitehaven,&lt;BR /&gt;
You could create a field extraction using this regex so you have all these fields related to a sourcetype.&lt;BR /&gt;
Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 13:28:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-custom-SourceType-with-multiple-delimiters-35-fields/m-p/493055#M194369</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-27T13:28:11Z</dc:date>
    </item>
  </channel>
</rss>

