<?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: An external script saves &amp;quot;host&amp;quot; values in a csv, but names the field after the first result. How do I get the file to name the field &amp;quot;host&amp;quot; to run an inputlookup? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/An-external-script-saves-quot-host-quot-values-in-a-csv-but/m-p/153981#M31294</link>
    <description>&lt;P&gt;The easiest way would be to change the external script to include the header, but if this is not an option we need to fix the lookup to force "host" header, this is what I would do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup puppet_results.csv | transpose|transpose|eval host='row 1'| fields - "row 1",column | outputlookup puppet_resultswithheader.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that would fix the column name as host and use the first value you had before as a value not as a header.&lt;/P&gt;

&lt;P&gt;then you can run your query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=_internal | dedup host | inputlookup append=t puppet_resultswithheader.csv | stats count by host | where count &amp;lt; 2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Apr 2015 21:29:17 GMT</pubDate>
    <dc:creator>aalanisr26</dc:creator>
    <dc:date>2015-04-22T21:29:17Z</dc:date>
    <item>
      <title>An external script saves "host" values in a csv, but names the field after the first result. How do I get the file to name the field "host" to run an inputlookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/An-external-script-saves-quot-host-quot-values-in-a-csv-but/m-p/153979#M31292</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;I have an external script that runs and saves the results in a file I called &lt;CODE&gt;puppet_results.csv&lt;/CODE&gt; in &lt;CODE&gt;$SPLUNK_HOME/etc/apps/search/lookups&lt;/CODE&gt;. I verified that it returns results by running &lt;CODE&gt;| inputlookup puppet_results.csv&lt;/CODE&gt; which returned 482 results so the data is there. &lt;/P&gt;

&lt;P&gt;So I created a search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | dedup host | inputlookup append=t puppet_results.csv | stats count by host | where count &amp;lt; 2 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the results of the initial search, but get no results from the "inputlookup" portion.&lt;/P&gt;

&lt;P&gt;The reason is that the field &lt;CODE&gt;host&lt;/CODE&gt; in the &lt;CODE&gt;puppet_results.csv&lt;/CODE&gt; from the script is not named "host". It's named after the first result in the file. &lt;/P&gt;

&lt;P&gt;Any idea on how I could get the file to name the field as "host"?&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2015 12:35:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/An-external-script-saves-quot-host-quot-values-in-a-csv-but/m-p/153979#M31292</guid>
      <dc:creator>tkwaller</dc:creator>
      <dc:date>2015-04-22T12:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: An external script saves "host" values in a csv, but names the field after the first result. How do I get the file to name the field "host" to run an inputlookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/An-external-script-saves-quot-host-quot-values-in-a-csv-but/m-p/153980#M31293</link>
      <description>&lt;P&gt;The easiest thing to do here would probably be to change your external script so that the first line of your CSV contains the field names of the columns.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2015 13:56:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/An-external-script-saves-quot-host-quot-values-in-a-csv-but/m-p/153980#M31293</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2015-04-22T13:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: An external script saves "host" values in a csv, but names the field after the first result. How do I get the file to name the field "host" to run an inputlookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/An-external-script-saves-quot-host-quot-values-in-a-csv-but/m-p/153981#M31294</link>
      <description>&lt;P&gt;The easiest way would be to change the external script to include the header, but if this is not an option we need to fix the lookup to force "host" header, this is what I would do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup puppet_results.csv | transpose|transpose|eval host='row 1'| fields - "row 1",column | outputlookup puppet_resultswithheader.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that would fix the column name as host and use the first value you had before as a value not as a header.&lt;/P&gt;

&lt;P&gt;then you can run your query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=_internal | dedup host | inputlookup append=t puppet_resultswithheader.csv | stats count by host | where count &amp;lt; 2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2015 21:29:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/An-external-script-saves-quot-host-quot-values-in-a-csv-but/m-p/153981#M31294</guid>
      <dc:creator>aalanisr26</dc:creator>
      <dc:date>2015-04-22T21:29:17Z</dc:date>
    </item>
  </channel>
</rss>

