<?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: My lookup in a macro works in a search, but why does it not work using savedsearch command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279576#M84478</link>
    <description>&lt;P&gt;The only interesting lines from search.log are:&lt;BR /&gt;
    ...&lt;BR /&gt;
    02-06-2017 11:12:35.917 INFO  LookupOperator - Assuming table name 'my_test.csv' is implicit filename.&lt;BR /&gt;
    02-06-2017 11:12:35.918 ERROR LookupOperator - Error in 'lookup' command: Could not find all of the specified destination fields in the lookup table.&lt;BR /&gt;
    ...&lt;BR /&gt;
    02-06-2017 11:12:35.930 INFO  ShutdownHandler - Shutdown complete in 281 microseconds&lt;BR /&gt;
    02-06-2017 11:12:35.931 ERROR dispatchRunner - RunDispatch::runDispatchThread threw error: Error in 'lookup' command: Could not find all of the specified destination fields in the lookup table.&lt;BR /&gt;
    [End]&lt;/P&gt;</description>
    <pubDate>Mon, 06 Feb 2017 19:16:02 GMT</pubDate>
    <dc:creator>rgsage</dc:creator>
    <dc:date>2017-02-06T19:16:02Z</dc:date>
    <item>
      <title>My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279571#M84473</link>
      <description>&lt;P&gt;We are on Splunk 6.2.1.  This is all in Splunk search...&lt;/P&gt;

&lt;P&gt;I have a macro with lookup which works fine in a simple search but when I save the search and attempt to invoke from &lt;CODE&gt;| savedsearch ...&lt;/CODE&gt; I get this error: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'lookup' command: Could not find all of the specified destination fields in the lookup table.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Details: lookup file my_test.csv like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key,value
A,1
B,2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And very simple macro my_macro like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;lookup my_test.csv key OUTPUT value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And very simple search "my_search" like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index [edited]
| eval key = "A"
| `my_macro` 
| table _time key value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So far everything works fine.  All rows have key=A, value=1. &lt;/P&gt;

&lt;P&gt;When I do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| savedsearch "my_search"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get error message: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Error in 'lookup' command: Could not find all of the specified destination fields in the lookup table."
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Job inspector shows eventSearch (only):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=my_index [Edited] | eval key = "A"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 18:17:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279571#M84473</guid>
      <dc:creator>rgsage</dc:creator>
      <dc:date>2017-02-06T18:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279572#M84474</link>
      <description>&lt;P&gt;Permissions...? Is the saved search running in an app context that has visibility to the macro? I suspect the macro is in your private user space and not visible by the saved search. Try setting permissions for your macro to 'global' and see if that changes things.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 18:27:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279572#M84474</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2017-02-06T18:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279573#M84475</link>
      <description>&lt;P&gt;Thank you for quick reply. Sorry I should have included in the details my_macro is saved as Sharing=Global, with Permissions: Read access for Everyone. &lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 18:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279573#M84475</guid>
      <dc:creator>rgsage</dc:creator>
      <dc:date>2017-02-06T18:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279574#M84476</link>
      <description>&lt;P&gt;Hmm, I just tested this on my local 6.5.0 instance without issues.&lt;BR /&gt;
Take a look at the search.log for your execution (there's a link to it a the top (and bottom) of the Job Inspector window and see if you can find any hints. &lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 18:54:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279574#M84476</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2017-02-06T18:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279575#M84477</link>
      <description>&lt;P&gt;What about lookup table file permissions?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 19:03:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279575#M84477</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-06T19:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279576#M84478</link>
      <description>&lt;P&gt;The only interesting lines from search.log are:&lt;BR /&gt;
    ...&lt;BR /&gt;
    02-06-2017 11:12:35.917 INFO  LookupOperator - Assuming table name 'my_test.csv' is implicit filename.&lt;BR /&gt;
    02-06-2017 11:12:35.918 ERROR LookupOperator - Error in 'lookup' command: Could not find all of the specified destination fields in the lookup table.&lt;BR /&gt;
    ...&lt;BR /&gt;
    02-06-2017 11:12:35.930 INFO  ShutdownHandler - Shutdown complete in 281 microseconds&lt;BR /&gt;
    02-06-2017 11:12:35.931 ERROR dispatchRunner - RunDispatch::runDispatchThread threw error: Error in 'lookup' command: Could not find all of the specified destination fields in the lookup table.&lt;BR /&gt;
    [End]&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 19:16:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279576#M84478</guid>
      <dc:creator>rgsage</dc:creator>
      <dc:date>2017-02-06T19:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279577#M84479</link>
      <description>&lt;P&gt;Lookup file was added directly to the filesystem (as with all our lookups), and looks like (from Settings/Lookups/Lookup table files page) in that case Splunk defaults to Sharing=Global.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 19:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279577#M84479</guid>
      <dc:creator>rgsage</dc:creator>
      <dc:date>2017-02-06T19:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279578#M84480</link>
      <description>&lt;P&gt;In general, programmers should avoid using keywords as variable names.  You never know when such mixed nomenclature will confuse the data plumbing. I'm suspecting that the issue in this case is either the variable name "value" or the action of the OUTPUT key word.  &lt;/P&gt;

&lt;P&gt;Try changing the code to the following - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;inkey,outvalue
 A,1
 B,2


 lookup my_test.csv inkey as mykey OUTPUT outvalue as myvalue


index=my_index [edited]
 | eval mykey = "A"
 | eval myvalue = "whocares"
 | `my_macro` 
 | table _time mykey myvalue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If either of my suspected issues is correct, that code should fix it.  &lt;/P&gt;

&lt;P&gt;(The variable names I wanted changed because I would normally use fillnull to set the value for the field "value", and value is a keyword used to set the value you are going to fill for nulls.)&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 20:32:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279578#M84480</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-06T20:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279579#M84481</link>
      <description>&lt;P&gt;Thank you for your reply! Turns out your second guess was correct: OUTPUT was the culprit. For some reason when used with savedsearch, the lookup must have an explicit OUTPUT foo AS something.  &lt;/P&gt;

&lt;P&gt;In my case this macro works in normal search, but not from savedsearch:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;lookup my_test.csv key OUTPUT value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This macro works in normal search, AND from savedsearch:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;lookup my_test.csv key OUTPUT value as value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is an interesting additional wrinkle that may help someone... If the lookup macro has a trailing space ("lookup my_test.csv OUTPUT value AS value ") it will again work in normal search but again NOT from savedsearch.  Wow. &lt;/P&gt;

&lt;P&gt;Perhaps @ssievert did not see this behavior because there are some Splunk bugs here that have been fixed since 6.2.1...  Thanks again! &lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 01:54:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279579#M84481</guid>
      <dc:creator>rgsage</dc:creator>
      <dc:date>2017-02-07T01:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279580#M84482</link>
      <description>&lt;P&gt;You're welcome.  Yes, I've come to trust that, if reading something makes me ITCH, there's probably a hidden gotcha.&lt;/P&gt;

&lt;P&gt;Twenty years ago, I'd tell my junior programmers when they showed me a creative way of doing something, "Well, &lt;EM&gt;I&lt;/EM&gt; wouldn't do it that way, but it ought to work."  &lt;/P&gt;

&lt;P&gt;Often, they'd be back an hour later to tell me about their new problem, and I'd remember. "Oh, yeah, THAT'S why I wouldn't do it that way."&lt;/P&gt;

&lt;P&gt;Nowadays, I just raise my eyebrow and say, "THIS PART makes me itch.  I'd rewrite that to do X, Y and Z."  Usually, they do.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:47:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279580#M84482</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-07T18:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: My lookup in a macro works in a search, but why does it not work using savedsearch command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279581#M84483</link>
      <description>&lt;P&gt;Of course, if somesoni2 shows me a creative way to do something, then I study it until it feels natural, find another application for it, then I put it in my toolbox.  &lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:49:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-lookup-in-a-macro-works-in-a-search-but-why-does-it-not-work/m-p/279581#M84483</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-07T18:49:47Z</dc:date>
    </item>
  </channel>
</rss>

