<?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: rex and eval in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/rex-and-eval/m-p/460196#M129818</link>
    <description>&lt;P&gt;thanks for checking it.&lt;/P&gt;

&lt;P&gt;So, here is what i am looking for.&lt;/P&gt;

&lt;P&gt;query: &lt;BR /&gt;
| makeresults &lt;BR /&gt;
|append [search index="index-name" probe_success instance="&lt;A href="https://teams-*" target="_blank"&gt;https://teams-*&lt;/A&gt;" |rex field=_raw "}\s(?\d[-+]?[0-9]*.?[0-9]+)"| dedup 1 instance]&lt;BR /&gt;
| eval instance1= if((instance == "&lt;A href="https://teams-instance1" target="_blank"&gt;https://teams-instance1&lt;/A&gt; AND stat == 1), "", "")&lt;BR /&gt;
| eval instance2= if((instance == "&lt;A href="https://teams-instance2" target="_blank"&gt;https://teams-instance2&lt;/A&gt; AND stat == 1), "", "")&lt;BR /&gt;
| eval svg_viz = "&lt;/P&gt;

&lt;P&gt;".instance1."&lt;BR /&gt;
".instance2."&lt;/P&gt;

&lt;P&gt;"&lt;BR /&gt;
| table svg_viz&lt;/P&gt;

&lt;P&gt;Here, svg_viz has to run only once after all check has been done replacing the variables in the svg definition. But what happens is that svg gets created for every event and i am not able to consolidate the checks.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 04:46:41 GMT</pubDate>
    <dc:creator>garumuga</dc:creator>
    <dc:date>2020-09-30T04:46:41Z</dc:date>
    <item>
      <title>rex and eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-and-eval/m-p/460194#M129816</link>
      <description>&lt;P&gt;I have a rex statement that parses multiple events and extracts the servers and its state:, something like below.&lt;/P&gt;

&lt;P&gt;index="index-name" "keyword" instance="&lt;A href="https://jenkins-*com"&gt;https://jenkins-*com&lt;/A&gt;" |rex field=_raw "}\s(?\d[-+]?[0-9]*.?[0-9]+)"| dedup 1 instance&lt;/P&gt;

&lt;P&gt;the above query returns as below&lt;BR /&gt;
Name       state&lt;BR /&gt;
instance1 1.00&lt;BR /&gt;
instance2 0.00&lt;BR /&gt;
instance3 1.00 .... so on&lt;/P&gt;

&lt;P&gt;I add eval statements after this query to check if specific instance and state is matched.&lt;/P&gt;

&lt;P&gt;this works, but the eval command gets repeated for all the occurrences of "instances"., like the following.&lt;/P&gt;

&lt;P&gt;Name       state     eval_output&lt;BR /&gt;
instance1 1.00      yes&lt;BR /&gt;
instance2 0.00      no&lt;BR /&gt;
instance3 1.00      yes&lt;/P&gt;

&lt;P&gt;But, what i would like to achieve is to break the looping, meaning after eval command is executed for all instances, i add another eval statement which just uses the output and not adding it to all instances. how can i achieve this? I have this problem while using svg app. &lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 20:21:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-and-eval/m-p/460194#M129816</guid>
      <dc:creator>garumuga</dc:creator>
      <dc:date>2020-03-26T20:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: rex and eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-and-eval/m-p/460195#M129817</link>
      <description>&lt;P&gt;That's normal behavior.  With some exceptions (like &lt;CODE&gt;addcoltotals&lt;/CODE&gt; and &lt;CODE&gt;stats&lt;/CODE&gt;), SPL commands are executed against each event fetched by the search.  If you don't want the results of an &lt;CODE&gt;eval&lt;/CODE&gt; to be seen, use &lt;CODE&gt;fields - foo&lt;/CODE&gt; to get rid of a field.&lt;/P&gt;

&lt;P&gt;That said, perhaps there's another way to solve your problem.  If you'll explain what you're trying to accomplish we may be able to find another way to do it.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 00:46:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-and-eval/m-p/460195#M129817</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-03-27T00:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: rex and eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-and-eval/m-p/460196#M129818</link>
      <description>&lt;P&gt;thanks for checking it.&lt;/P&gt;

&lt;P&gt;So, here is what i am looking for.&lt;/P&gt;

&lt;P&gt;query: &lt;BR /&gt;
| makeresults &lt;BR /&gt;
|append [search index="index-name" probe_success instance="&lt;A href="https://teams-*" target="_blank"&gt;https://teams-*&lt;/A&gt;" |rex field=_raw "}\s(?\d[-+]?[0-9]*.?[0-9]+)"| dedup 1 instance]&lt;BR /&gt;
| eval instance1= if((instance == "&lt;A href="https://teams-instance1" target="_blank"&gt;https://teams-instance1&lt;/A&gt; AND stat == 1), "", "")&lt;BR /&gt;
| eval instance2= if((instance == "&lt;A href="https://teams-instance2" target="_blank"&gt;https://teams-instance2&lt;/A&gt; AND stat == 1), "", "")&lt;BR /&gt;
| eval svg_viz = "&lt;/P&gt;

&lt;P&gt;".instance1."&lt;BR /&gt;
".instance2."&lt;/P&gt;

&lt;P&gt;"&lt;BR /&gt;
| table svg_viz&lt;/P&gt;

&lt;P&gt;Here, svg_viz has to run only once after all check has been done replacing the variables in the svg definition. But what happens is that svg gets created for every event and i am not able to consolidate the checks.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:46:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-and-eval/m-p/460196#M129818</guid>
      <dc:creator>garumuga</dc:creator>
      <dc:date>2020-09-30T04:46:41Z</dc:date>
    </item>
  </channel>
</rss>

