<?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 extract the same fields from multiple log formats? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283054#M85531</link>
    <description>&lt;P&gt;Sridhar, &lt;BR /&gt;
 I had come across a similar problem. I am explaining the approach I have taken, may be useful for you.&lt;BR /&gt;
 1. Combine all the three log files into an eventtype.&lt;BR /&gt;
Example: eventtype myevent="index=* host=hostname source="source1.log" OR source="source2.log"&lt;BR /&gt;
 2. in each log file define field extracts for the fields as you are currently doing. Use same field name across files (or use field aliases)&lt;BR /&gt;
 3. search for the common fields using eventtype.&lt;BR /&gt;&lt;BR /&gt;
 example: eventtype="myevent" ID=* &lt;BR /&gt;
this query will give you values for ID from all three files.&lt;BR /&gt;
-Bharath&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2015 06:01:46 GMT</pubDate>
    <dc:creator>bkumarm</dc:creator>
    <dc:date>2015-12-17T06:01:46Z</dc:date>
    <item>
      <title>How to extract the same fields from multiple log formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283051#M85528</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I have a 3 different log files and there are 8 different formats in them. All formats have the same fields in them (cpu,memory etc.) and regex is similar. Hence, based on the system name, I should get its values (level, OS, primary_drive). Below is the sample log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Nov 08 12:55:07 servername: {"cpu_cores":"4","ram_size":"6","system_name":"NAME1","level":"info","OS":"WINDOWS","primary_drive":"C"}
Nov 08 12:54:07 servername: {"cpu_cores":"2","ram_size":"6","BIOS_Version":"A12","system_model":"Opti","system_name":"NAME2","level":"info","OS":"WINDOWS","primary_drive":"D"}
Nov 08 12:52:07 servername: {"cpu_cores":"4","ram_size":"4","system_name":"NAME3","level":"info","OS":"WINDOWS","primary_drive":""}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I did here is I gave the 2 different regex for 2 log formats in props.conf.  Hence I get both these log formats in and other 6 formats are ignored         &lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::/source/file name]
TRANSFORMS-set = outside,inside
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[outside]
REGEX =.
DEST_KEY = queue
FORMAT = nullQueue

[inside]
REGEX = &amp;lt;{\"(?:cpu_cores\")\:\"(?&amp;lt;cpu_cores&amp;gt;.+)\"\,\"(?:ram_size\")\:\"(?&amp;lt;ram_size&amp;gt;.+)\"\,\"(?:system_name\")\:\"(?&amp;lt;system_name&amp;gt;.+)\"\,\"(?:level\")\:\"(?&amp;lt;level&amp;gt;.+)\"\,\"(?:OS\")\:\"(?&amp;lt;OS&amp;gt;.+)\,\"(?:primary_drive\")\:\"(?&amp;lt;primary_drive&amp;gt;\w)&amp;gt;

REGEX =  {\"(?:cpu_cores\")\:\"(?&amp;lt;cpu_cores&amp;gt;.+)\"\,\"(?:ram_size\")\:\"(?&amp;lt;ram_size&amp;gt;.+)\"\,\"(?:BIOS_Version\")\:\"(?&amp;lt;BIOS_Version&amp;gt;.+)\"\,\"(?:system_model\")\:\"(?&amp;lt;system_model&amp;gt;.+)\"\,\"(?:system_name\")\:\"(?&amp;lt;system_name&amp;gt;.+)\"\,\"(?:level\")\:\"(?&amp;lt;level&amp;gt;.+)\"\,\"(?:OS\")\:\"(?&amp;lt;OS&amp;gt;.+)\,\"(?:primary_drive\")\:\"(?&amp;lt;primary_drive&amp;gt;\w) 

DEST_KEY = queue
FORMAT = indexQueue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also for field extraction, I made the change in props.conf as below, but I get the field extraction for only regex2. The field extraction for regex 1 is not working, hence it's not getting extracted. I am not sure whether same field getting extracted for different patterns might be a problem. Can someone help me, so that I should get field extractions for both regex types?&lt;/P&gt;

&lt;P&gt;props.conf &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[my_sourcetype]
EXTRACT-fields = &amp;lt;{\"(?:cpu_cores\")\:\"(?&amp;lt;cpu_cores&amp;gt;.+)\"\,\"(?:ram_size\")\:\"(?&amp;lt;ram_size&amp;gt;.+)\"\,\"(?:system_name\")\:\"(?&amp;lt;system_name&amp;gt;.+)\"\,\"(?:level\")\:\"(?&amp;lt;level&amp;gt;.+)\"\,\"(?:OS\")\:\"(?&amp;lt;OS&amp;gt;.+)\,\"(?:primary_drive\")\:\"(?&amp;lt;primary_drive&amp;gt;\w)&amp;gt;

EXTRACT-fields =  {\"(?:cpu_cores\")\:\"(?&amp;lt;cpu_cores&amp;gt;.+)\"\,\"(?:ram_size\")\:\"(?&amp;lt;ram_size&amp;gt;.+)\"\,\"(?:BIOS_Version\")\:\"(?&amp;lt;BIOS_Version&amp;gt;.+)\"\,\"(?:system_model\")\:\"(?&amp;lt;system_model&amp;gt;.+)\"\,\"(?:system_name\")\:\"(?&amp;lt;system_name&amp;gt;.+)\"\,\"(?:level\")\:\"(?&amp;lt;level&amp;gt;.+)\"\,\"(?:OS\")\:\"(?&amp;lt;OS&amp;gt;.+)\,\"(?:primary_drive\")\:\"(?&amp;lt;primary_drive&amp;gt;\w) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2015 21:32:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283051#M85528</guid>
      <dc:creator>SridharS</dc:creator>
      <dc:date>2015-12-16T21:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the same fields from multiple log formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283052#M85529</link>
      <description>&lt;P&gt;How about trying something like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX ="([^"]+)":"([^"]*),?
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2015 22:04:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283052#M85529</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2015-12-16T22:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the same fields from multiple log formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283053#M85530</link>
      <description>&lt;P&gt;This works. But in my case I need to provide 2 different regex patterns for a single log file. When I give the 2 patterns in props.conf it extracts only one in result(where the fields for both patterns are same). &lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 03:34:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283053#M85530</guid>
      <dc:creator>SridharS</dc:creator>
      <dc:date>2015-12-17T03:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the same fields from multiple log formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283054#M85531</link>
      <description>&lt;P&gt;Sridhar, &lt;BR /&gt;
 I had come across a similar problem. I am explaining the approach I have taken, may be useful for you.&lt;BR /&gt;
 1. Combine all the three log files into an eventtype.&lt;BR /&gt;
Example: eventtype myevent="index=* host=hostname source="source1.log" OR source="source2.log"&lt;BR /&gt;
 2. in each log file define field extracts for the fields as you are currently doing. Use same field name across files (or use field aliases)&lt;BR /&gt;
 3. search for the common fields using eventtype.&lt;BR /&gt;&lt;BR /&gt;
 example: eventtype="myevent" ID=* &lt;BR /&gt;
this query will give you values for ID from all three files.&lt;BR /&gt;
-Bharath&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 06:01:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283054#M85531</guid>
      <dc:creator>bkumarm</dc:creator>
      <dc:date>2015-12-17T06:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the same fields from multiple log formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283055#M85532</link>
      <description>&lt;P&gt;Hi, finally I found it. Instead of giving EXTRACT-fields = regex, I gave the all the field names . &lt;/P&gt;

&lt;P&gt;EXTRACT-field1, field2, field3....... = regex 1&lt;BR /&gt;
EXTRACT-field1, field2, field3....... = regex 2&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 14:15:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-same-fields-from-multiple-log-formats/m-p/283055#M85532</guid>
      <dc:creator>SridharS</dc:creator>
      <dc:date>2015-12-17T14:15:26Z</dc:date>
    </item>
  </channel>
</rss>

