<?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: DB Query with app Splunk DB Connect inside of Eval Expression in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109965#M183544</link>
    <description>&lt;P&gt;I guess its not possible. The macro workaround is not working as I expected.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jun 2014 17:48:39 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2014-06-18T17:48:39Z</dc:date>
    <item>
      <title>DB Query with app Splunk DB Connect inside of Eval Expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109961#M183540</link>
      <description>&lt;P&gt;So, I'm trying to run DB queries with the Splunk DB Connect app inside of the eval "case" function. So, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=eph | rex "(?P&amp;lt;Type&amp;gt;PaymentInstruction)"| rex "(?P&amp;lt;Type&amp;gt;OPIC)" | rex "(?P&amp;lt;EPHID&amp;gt;EPH\d+)"
| eval EPHID = case( isnull(Type), EPHID, Type == "PaymentInstruction", dbquery "mysql" "SELECT DISPLAYTRANSACTIONID FROM XXXX WHERE paymentinstructionkey = 'EntityKey'", Type == "OPIC", dbquery "mysql" "SELECT DISPLAYTRANSACTIONID FROM XXXX WHERE opickey='EntityKey'") 
| table EPHID Type _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So if the event has a Type, I want to query the database to get its EPHID and plug it into the table to completely fill the table. However, I keep getting the following issue:&lt;/P&gt;

&lt;P&gt;"Error in 'eval' command: The expression is malformed. Expected )."&lt;/P&gt;

&lt;P&gt;Any ideas?? Thanks!!!&lt;/P&gt;

&lt;P&gt;EDIT:&lt;/P&gt;

&lt;P&gt;Note, this search works properly:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=eph sourcetype=websphere_trlog_sysout AND ("*EPH14*" OR "*Entitykey*") AND (`EPH-HPOV-Keyword` OR EPH-alerts) | rex 
"EDT] (?P&amp;lt;TaskID&amp;gt;\w{8})" | where TaskID != "" | rex "Entity Key: (?P&amp;lt;EntityKey&amp;gt;\d+)" | rex "entityKey=(?P&amp;lt;EntityKey&amp;gt;\d+.\d+.\d+)" 
| rex "EntityKey:(?P&amp;lt;EntityKey&amp;gt;\d+)" | rex "(?P&amp;lt;EPHID&amp;gt;EPH\d+)" | rex "(?P&amp;lt;Type&amp;gt;PaymentInstruction)"| rex "(?P&amp;lt;Type&amp;gt;OPIC)" |convert ctime(_time) as timestamp 
| eval EPHID = case( isnull(Type), EPHID, Type == "PaymentInstruction", "PI", Type = "OPIC", "OP")
| table EntityKey EPHID TaskID Type timestamp _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So I don't think that passing fields is the issue. It must be something with the DB query clause.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2014 15:10:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109961#M183540</guid>
      <dc:creator>edschembor</dc:creator>
      <dc:date>2014-06-18T15:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: DB Query with app Splunk DB Connect inside of Eval Expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109962#M183541</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=eph | rex "(?P&amp;lt;Type&amp;gt;PaymentInstruction)"| rex "(?P&amp;lt;Type&amp;gt;OPIC)" | rex "(?P&amp;lt;EPHID&amp;gt;EPH\d+)"
| eval EPHID = case( isnull(Type), EPHID, Type == "PaymentInstruction", [|dbquery "mysql" "SELECT DISPLAYTRANSACTIONID FROM XXXX WHERE paymentinstructionkey = 'EntityKey'" | eval DISPLAYTRANSACTIONID="\"".DISPLAYTRANSACTIONID."\"" | return $DISPLAYTRANSACTIONID ], Type == "OPIC", [| dbquery "mysql" "SELECT DISPLAYTRANSACTIONID FROM XXXX WHERE opickey='EntityKey'" | eval DISPLAYTRANSACTIONID="\"".DISPLAYTRANSACTIONID."\"" | return $DISPLAYTRANSACTIONID ]) 
| table EPHID Type _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;One question though, the term 'EntityKey' is a literal string or its a field in the main result?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2014 15:57:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109962#M183541</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-06-18T15:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: DB Query with app Splunk DB Connect inside of Eval Expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109963#M183542</link>
      <description>&lt;P&gt;Entity key is a field. I have a regex: " rex "Entity Key: (?P&lt;ENTITYKEY&gt;\d+)"" but took it out to make the question shorter&lt;/ENTITYKEY&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2014 16:00:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109963#M183542</guid>
      <dc:creator>edschembor</dc:creator>
      <dc:date>2014-06-18T16:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: DB Query with app Splunk DB Connect inside of Eval Expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109964#M183543</link>
      <description>&lt;P&gt;I did the updated method with the macro and still am getting the issue: &lt;BR /&gt;
"Error in 'eval' command: The expression is malformed. An unexpected character is reached at ', "Type"== "OPIC", )'."&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2014 17:01:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109964#M183543</guid>
      <dc:creator>edschembor</dc:creator>
      <dc:date>2014-06-18T17:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: DB Query with app Splunk DB Connect inside of Eval Expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109965#M183544</link>
      <description>&lt;P&gt;I guess its not possible. The macro workaround is not working as I expected.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2014 17:48:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109965#M183544</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-06-18T17:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: DB Query with app Splunk DB Connect inside of Eval Expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109966#M183545</link>
      <description>&lt;P&gt;Is there possibly a way to do it with a script?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2014 18:20:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109966#M183545</guid>
      <dc:creator>edschembor</dc:creator>
      <dc:date>2014-06-18T18:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: DB Query with app Splunk DB Connect inside of Eval Expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109967#M183546</link>
      <description>&lt;P&gt;Maybe a python script?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 12:17:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109967#M183546</guid>
      <dc:creator>edschembor</dc:creator>
      <dc:date>2014-06-19T12:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: DB Query with app Splunk DB Connect inside of Eval Expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109968#M183547</link>
      <description>&lt;P&gt;Solved by just using a DB Lookup instead&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2014 18:46:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Query-with-app-Splunk-DB-Connect-inside-of-Eval-Expression/m-p/109968#M183547</guid>
      <dc:creator>edschembor</dc:creator>
      <dc:date>2014-06-25T18:46:24Z</dc:date>
    </item>
  </channel>
</rss>

