<?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 How can I add output of a search as a new column to existing csv ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386347#M172113</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;
I have an existing .csv named "test.csv". In this csv file, there are fields named srcip and time. Also I have a search getting hostnames for ip's in that csv. Lookup is OK and my search is totally getting the right results. The thing I want to do is updating test.csv with the output of my results. For example I have 1.1.1.1 IP in test.csv. And my search gets "test-pc" hostname for that IP. After my search is completed I want :&lt;BR /&gt;
- Create a new column in csv as "Host Name"&lt;BR /&gt;
- Match IP's between csv and my search&lt;BR /&gt;
- Add hostname for matching IP's to existing test.csv&lt;/P&gt;

&lt;P&gt;I tried outputlookup command with append=true but It didn't work.&lt;BR /&gt;
Hope you help me,&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 01 Apr 2019 13:04:16 GMT</pubDate>
    <dc:creator>batuhankutluca</dc:creator>
    <dc:date>2019-04-01T13:04:16Z</dc:date>
    <item>
      <title>How can I add output of a search as a new column to existing csv ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386347#M172113</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I have an existing .csv named "test.csv". In this csv file, there are fields named srcip and time. Also I have a search getting hostnames for ip's in that csv. Lookup is OK and my search is totally getting the right results. The thing I want to do is updating test.csv with the output of my results. For example I have 1.1.1.1 IP in test.csv. And my search gets "test-pc" hostname for that IP. After my search is completed I want :&lt;BR /&gt;
- Create a new column in csv as "Host Name"&lt;BR /&gt;
- Match IP's between csv and my search&lt;BR /&gt;
- Add hostname for matching IP's to existing test.csv&lt;/P&gt;

&lt;P&gt;I tried outputlookup command with append=true but It didn't work.&lt;BR /&gt;
Hope you help me,&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 13:04:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386347#M172113</guid>
      <dc:creator>batuhankutluca</dc:creator>
      <dc:date>2019-04-01T13:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add output of a search as a new column to existing csv ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386348#M172114</link>
      <description>&lt;P&gt;Whats' the full search that you've tried? Also, when you said it didn't work, what error or wrong result you were getting?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 19:13:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386348#M172114</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-04-01T19:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add output of a search as a new column to existing csv ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386349#M172115</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Search for hostname here
| rename whatever_field_has_IP AS IP
| appendpipe [|inputlookup test.csv | rename whatever_field_has_IP AS IP]
| stats values(*) AS * BY IP
| sort 0 IP(IP)
| outputlookup test.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 20:02:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386349#M172115</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-01T20:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add output of a search as a new column to existing csv ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386350#M172116</link>
      <description>&lt;P&gt;sourcetype=firewall action=pass action=proxy&lt;BR /&gt;
| bin _time span=5m&lt;BR /&gt;
| dedup srcip&lt;BR /&gt;
| eval Time = strftime(_time,"%Y-%m-%d %H:%M:%S")&lt;BR /&gt;
| table Time, srcip, srcport, dstip, dstport, app&lt;BR /&gt;
| outputlookup vpn.csv&lt;/P&gt;

&lt;P&gt;This is my first search to create a lookup.&lt;/P&gt;

&lt;P&gt;And my 2nd search is &lt;/P&gt;

&lt;P&gt;sourcetype=dhcp &lt;BR /&gt;
| lookup vpn.csv srcip AS dest_ip &lt;BR /&gt;
| search Time=*&lt;BR /&gt;
| eval event_time=strptime(Time,"%Y-%m-%d %H:%M:%S") &lt;BR /&gt;
| where _time &amp;lt; event_time &lt;BR /&gt;
| stats latest(dest_nt_host) as dest_nt_host by dest_ip&lt;BR /&gt;
| outputlookup append=true vpn.csv&lt;/P&gt;

&lt;P&gt;Actually I'm not getting any errors, just my lookup is not updating. That's the problem.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:00:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386350#M172116</guid>
      <dc:creator>batuhankutluca</dc:creator>
      <dc:date>2020-09-30T00:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add output of a search as a new column to existing csv ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386351#M172117</link>
      <description>&lt;P&gt;Thanks for your help but this one is overriding the results of an existing csv. I just want to do that steps:&lt;BR /&gt;
- Create a new column in csv as "Host Name"&lt;BR /&gt;
- Match IP's between csv and my search&lt;BR /&gt;
- Add hostname for matching IP's to existing test.csv&lt;/P&gt;

&lt;P&gt;I added my searches above as a comment if you want to check.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 05:41:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386351#M172117</guid>
      <dc:creator>batuhankutluca</dc:creator>
      <dc:date>2019-04-02T05:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add output of a search as a new column to existing csv ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386352#M172118</link>
      <description>&lt;P&gt;My answer does exactly what you are describing.  If you are not writing answer back to &lt;CODE&gt;test.csv&lt;/CODE&gt; then delete the &lt;CODE&gt;| outputlookup test.csv&lt;/CODE&gt; line.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 05:49:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386352#M172118</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-02T05:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add output of a search as a new column to existing csv ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386353#M172119</link>
      <description>&lt;P&gt;I want to write results back to csv just for the matching ip's as a new column. Your query works like overriding all existing columns and rows and write back the new search's results to test.csv. That's why I said like that.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 05:54:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386353#M172119</guid>
      <dc:creator>batuhankutluca</dc:creator>
      <dc:date>2019-04-02T05:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add output of a search as a new column to existing csv ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386354#M172120</link>
      <description>&lt;P&gt;I think I have figured it out somehow but still don't know why is your search doesn't work as I wanted. Maybe If I upload some screenshots, It will be more clear for you.&lt;/P&gt;

&lt;P&gt;This is my first search with the output csv.&lt;/P&gt;

&lt;P&gt;--&lt;BR /&gt;
`sourcetype=firewall action=pass action=proxy&lt;BR /&gt;
| bin _time span=5m&lt;BR /&gt;
| dedup srcip&lt;BR /&gt;
| eval Time = strftime(_time,"%Y-%m-%d %H:%M:%S")&lt;BR /&gt;
| table Time, srcip, srcport, dstip&lt;BR /&gt;
| rename srcip AS IP&lt;/P&gt;

&lt;H2&gt;| outputlookup vpn.csv`&lt;/H2&gt;

&lt;P&gt;This is my 2nd search with the output csv.&lt;/P&gt;

&lt;P&gt;--&lt;BR /&gt;
`index=server sourcetype=dhcp&lt;BR /&gt;
| lookup vpn.csv srcip AS dest_ip &lt;BR /&gt;
| search Time=* &lt;BR /&gt;
| eval event_time=strptime(Time,"%Y-%m-%d %H:%M:%S") &lt;BR /&gt;
| where _time &amp;lt; event_time &lt;BR /&gt;
| stats latest(dest_nt_host) as dest_nt_host max(_time) as _time by dest_ip&lt;BR /&gt;
| sort - _time&lt;BR /&gt;
| rename dest_ip AS IP&lt;/P&gt;

&lt;H2&gt;| outputlookup vpn2.csv`&lt;/H2&gt;

&lt;P&gt;And the result is like that &lt;/P&gt;

&lt;P&gt;--&lt;BR /&gt;
`| inputlookup vpn.csv &lt;BR /&gt;
| join IP&lt;BR /&gt;
    [inputlookup vpn2.csv]&lt;/P&gt;

&lt;H2&gt;| outputlookup vpn3.csv`&lt;/H2&gt;

&lt;P&gt;Now it works as I wanted. That's what I was trying to explain. But I'm still open for advices.&lt;/P&gt;

&lt;P&gt;Images don't show up somehow.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:00:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-add-output-of-a-search-as-a-new-column-to-existing-csv/m-p/386354#M172120</guid>
      <dc:creator>batuhankutluca</dc:creator>
      <dc:date>2020-09-30T00:00:39Z</dc:date>
    </item>
  </channel>
</rss>

