<?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: multiple headers in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49563#M11902</link>
    <description>&lt;P&gt;If I understand you correctly you're trying to create a conditional extraction so when a line matches one regex, one delims-based extraction will be applied and if it matches the other regex the other extraction will be used. It doesn't work that way. (for good reasons - which one would Splunk decide to use if both regexes match?)&lt;/P&gt;

&lt;P&gt;You can only define one delims-based extraction at a time, so given one sourcetype you can't have multiple extractions like that. What you could do is create two regex-based extractions instead that do the same thing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Transaction_Usage_RDR]
REGEX = ^([^,]+),([^,]+),([^,]+),([^,]+)$
FORMAT = TIMESTAMP::$1 RDR_ID::$2 SUBSCRIBER_ID::$3 CLIENT_IP::$4

[Block_RDR]
REGEX = ^([^,]+),([^,]+)([^,]+)([^,]+)([^,]+)$
FORMAT = TIMESTAMP::$1 RDR_ID::$2 SUBSCRIBER_ID::$3 SKIPPED_SESSIONS:$4 CLIENT_IP::$5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 04 Mar 2013 09:06:58 GMT</pubDate>
    <dc:creator>Ayn</dc:creator>
    <dc:date>2013-03-04T09:06:58Z</dc:date>
    <item>
      <title>multiple headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49562#M11901</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I have a couple of comma separated cisco log files which is suppose to have different set of headers or fields. The said log files have common fields like so:&lt;/P&gt;

&lt;P&gt;header#1: Timestamp,RDR_ID,SUBSCRIBER_ID,CLIENT_IP&lt;BR /&gt;
header#2: Timestamp,RDR_ID,SUBSCRIBER_ID,SKIPPED_SESSIONS,CLIENT_IP&lt;/P&gt;

&lt;P&gt;sample data#1:&lt;BR /&gt;
1361171830137,4042321984,&lt;A href="mailto:001ffb25b1d1@smartbro.net" target="_blank"&gt;001ffb25b1d1@smartbro.net&lt;/A&gt;,192.168.1.1&lt;BR /&gt;
1361171830473,4042321984,&lt;A href="mailto:001ffb0f90bb@smartbro.net" target="_blank"&gt;001ffb0f90bb@smartbro.net&lt;/A&gt;,192.168.1.2&lt;BR /&gt;
1361171831107,4042321984,&lt;A href="mailto:001ffb0f90bb@smartbro.net" target="_blank"&gt;001ffb0f90bb@smartbro.net&lt;/A&gt;,192.168.1.3&lt;/P&gt;

&lt;P&gt;sample data#2&lt;BR /&gt;
1361171830137,4042323000,&lt;A href="mailto:001ffb25b1d1@smartbro.net" target="_blank"&gt;001ffb25b1d1@smartbro.net&lt;/A&gt;,0,192.168.1.1&lt;BR /&gt;
1361171830473,4042323000,&lt;A href="mailto:001ffb0f90bb@smartbro.net" target="_blank"&gt;001ffb0f90bb@smartbro.net&lt;/A&gt;,1,192.168.1.2&lt;BR /&gt;
1361171831107,4042323000,&lt;A href="mailto:001ffb0f90bb@smartbro.net" target="_blank"&gt;001ffb0f90bb@smartbro.net&lt;/A&gt;,0.192.168.1.3&lt;/P&gt;

&lt;P&gt;my props.conf&lt;BR /&gt;
[smart_sce_sourcetype]&lt;BR /&gt;
REPORTS-multi = Transaction_Usage_RDR, Block_RDR&lt;/P&gt;

&lt;P&gt;my transforms.conf&lt;BR /&gt;
[Transaction_Usage_RDR]&lt;BR /&gt;
REGEX="\W4042323000,"&lt;BR /&gt;
DELIMS=","&lt;BR /&gt;
FIELDS="TIMESTAMP","RDR_ID","SUBSCRIBER_ID","CLIENT_IP"&lt;/P&gt;

&lt;P&gt;[Block_RDR]&lt;BR /&gt;
REGEX="\W4042321984,"&lt;BR /&gt;
DELIMS=","&lt;BR /&gt;
FIELDS="TIMESTAMP","RDR_ID","SUBSCRIBER_ID","SKIPPED_SESSIONS","CLIENT_IP"&lt;/P&gt;

&lt;P&gt;The RDR_ID(2nd column of the actual data) determines w/c header to use. You'll notice this on my regex. The 2 sample data are indexed and both headers are generated but client_ip data is going on the skipped_sessions. Also some of the columns are missing. I removed the other headers for briefness of presenting the problem. Generally speaking the indexed data is messed up. Kindly advice.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:26:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49562#M11901</guid>
      <dc:creator>adomila</dc:creator>
      <dc:date>2020-09-28T13:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: multiple headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49563#M11902</link>
      <description>&lt;P&gt;If I understand you correctly you're trying to create a conditional extraction so when a line matches one regex, one delims-based extraction will be applied and if it matches the other regex the other extraction will be used. It doesn't work that way. (for good reasons - which one would Splunk decide to use if both regexes match?)&lt;/P&gt;

&lt;P&gt;You can only define one delims-based extraction at a time, so given one sourcetype you can't have multiple extractions like that. What you could do is create two regex-based extractions instead that do the same thing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Transaction_Usage_RDR]
REGEX = ^([^,]+),([^,]+),([^,]+),([^,]+)$
FORMAT = TIMESTAMP::$1 RDR_ID::$2 SUBSCRIBER_ID::$3 CLIENT_IP::$4

[Block_RDR]
REGEX = ^([^,]+),([^,]+)([^,]+)([^,]+)([^,]+)$
FORMAT = TIMESTAMP::$1 RDR_ID::$2 SUBSCRIBER_ID::$3 SKIPPED_SESSIONS:$4 CLIENT_IP::$5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Mar 2013 09:06:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49563#M11902</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-03-04T09:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: multiple headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49564#M11903</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
This works, except when it encounters a blank(not space or not whitespace) just the comma(or null) like so ,,, data, it will not work. It will still index but some of the fields although not blank will be affected and will not be index if it falls on the same column  with blank data &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; I tried to include |(OR regex char) then \S on the regex but still not working. Kindly advice.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 04:21:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49564#M11903</guid>
      <dc:creator>adomila</dc:creator>
      <dc:date>2013-03-05T04:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: multiple headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49565#M11904</link>
      <description>&lt;P&gt;You could just change the &lt;CODE&gt;+&lt;/CODE&gt; sign to &lt;CODE&gt;*&lt;/CODE&gt;. &lt;CODE&gt;+&lt;/CODE&gt; means "1 or more of the preceding" whereas &lt;CODE&gt;*&lt;/CODE&gt; means "0 or more of the preceding" so if there's no match at all it should work fine anyway.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 11:03:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49565#M11904</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-03-05T11:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: multiple headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49566#M11905</link>
      <description>&lt;P&gt;Finally got it working. Many many thanks Ayn ^_^&lt;/P&gt;

&lt;P&gt;Just a follow up question, but this is with regards to another project, similar in nature; if the data delimiter is a pipe(not a comma) character like so "|" then I would need to replace the second comma with the said pipe character, i.e. ([^,]&lt;EM&gt;)|([^,]&lt;/EM&gt;)|([^,]*| ...). So sorry, my regex know-how is a bit messy. tia(tnx in advance)&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2013 05:16:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49566#M11905</guid>
      <dc:creator>adomila</dc:creator>
      <dc:date>2013-03-11T05:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: multiple headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49567#M11906</link>
      <description>&lt;P&gt;Just replace the commas with pipes - but you need to escape the pipes ("&lt;CODE&gt;\|&lt;/CODE&gt;") because pipes are special characters in regular expressions.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2013 08:53:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-headers/m-p/49567#M11906</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-03-11T08:53:14Z</dc:date>
    </item>
  </channel>
</rss>

