<?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 Handle Metadata in File Headers in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143756#M39957</link>
    <description>&lt;P&gt;I forgot, a subsearch could work if you have unique file sources.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[search username=myUser | dedup source | table source] myothercondition=condition&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;the sub search will return the source name of the events that contains the username, and it will become a search condition in the man search.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Feb 2014 00:21:30 GMT</pubDate>
    <dc:creator>yannK</dc:creator>
    <dc:date>2014-02-11T00:21:30Z</dc:date>
    <item>
      <title>How to Handle Metadata in File Headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143754#M39955</link>
      <description>&lt;P&gt;I am using Splunk to collect data from log files generated by a thick client application. The log files contain metadata in the header relating to the user that logged on. I want to be able to search for events using the metadata in the file header (example below). &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;username: myUser
hostname: myHost
10/02/2014 13:12:03 INFO User did some stuff
10/02/2014 13:12:41 INFO User did some more stuff
10/02/2014 13:14:26 WARNING User did some stuff they weren't supposed to!
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this example a search for 'username=myUser' would return all three events shown. Is that possible?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2014 13:18:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143754#M39955</guid>
      <dc:creator>chrissale</dc:creator>
      <dc:date>2014-02-10T13:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to Handle Metadata in File Headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143755#M39956</link>
      <description>&lt;P&gt;Not easily because &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;the fields username and hostname will be present in the first events (with a timestamp that will be unpredictable)&lt;/LI&gt;
&lt;LI&gt;Then the other events will be all individuals, and not contain the username and hostname information.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;If your log files are unique (unique filename), you could build a lookup to link : the source and the username and hostname&lt;BR /&gt;
then when searching use the lookup to add those fields to the events of this particular source.&lt;BR /&gt;
see &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/Search/Useexternalfieldlookups"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.1/Search/Useexternalfieldlookups&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Otherwise, you should change you method of login, and maybe add the username and hostname in the source.&lt;BR /&gt;
the extract them at search time with a rex command.&lt;/P&gt;

&lt;P&gt;or in the path, example : &lt;CODE&gt;/path/to/my/file/&amp;lt;host&amp;gt;/&amp;lt;username&amp;gt;/file.log&lt;/CODE&gt;&lt;BR /&gt;
you can have the host field extracted at index time with &lt;CODE&gt;host_segment&lt;/CODE&gt; or &lt;CODE&gt;host_regex&lt;/CODE&gt;, see &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/Data/Setadefaulthostforaninput"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.1/Data/Setadefaulthostforaninput&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2014 00:18:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143755#M39956</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2014-02-11T00:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to Handle Metadata in File Headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143756#M39957</link>
      <description>&lt;P&gt;I forgot, a subsearch could work if you have unique file sources.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[search username=myUser | dedup source | table source] myothercondition=condition&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;the sub search will return the source name of the events that contains the username, and it will become a search condition in the man search.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2014 00:21:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143756#M39957</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2014-02-11T00:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to Handle Metadata in File Headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143757#M39958</link>
      <description>&lt;P&gt;Thanks for the response yannK. I like where you are going with this but unfortunately I can't guarantee that the source name is unique or influence the naming strategy for the file. I am going to see if I can create a custom field at indexing time that uniquely identifies the file (CRC?) and use that for the lookup.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2014 11:45:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143757#M39958</guid>
      <dc:creator>chrissale</dc:creator>
      <dc:date>2014-02-11T11:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to Handle Metadata in File Headers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143758#M39959</link>
      <description>&lt;P&gt;There is a possibility is to add a meta field at index time per monitor in the inputs.conf, but it will not be dynamic per files, So not really what you want.&lt;/P&gt;

&lt;P&gt;The only real solution is to format your events to add the fields to every lines before monitoring, Or create a custom scripted input to replace the monitor, and add then on the fly.&lt;BR /&gt;
see &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/AdvancedDev/ScriptedInputsIntro"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.1/AdvancedDev/ScriptedInputsIntro&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2014 18:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Handle-Metadata-in-File-Headers/m-p/143758#M39959</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2014-02-11T18:03:36Z</dc:date>
    </item>
  </channel>
</rss>

