<?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: How to use eval on JSON data in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-on-JSON-data/m-p/194723#M56153</link>
    <description>&lt;P&gt;do like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rename global.container.* AS  * | eval attr= if(attr==true, "attr", "opposite") |....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;then you can use like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;....| rename global.container.* AS  * | eval attr= if(attr==true, "attr", "opposite") | stats count by attr
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Mar 2015 17:10:17 GMT</pubDate>
    <dc:creator>fdi01</dc:creator>
    <dc:date>2015-03-25T17:10:17Z</dc:date>
    <item>
      <title>How to use eval on JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-on-JSON-data/m-p/194722#M56152</link>
      <description>&lt;P&gt;I'm going to suggest this is a bug, and I believe I've a workaround. I wonder if I've missed something. &lt;/P&gt;

&lt;P&gt;My JSON is of form attr=true or attr=false, and I want to put this into a graph. However, it's a little bit down, so it's global.container.attr&lt;/P&gt;

&lt;P&gt;So, I have:&lt;BR /&gt;
| strcat otherterm " " global.container.attr combinedterm | ... | stats count  by combinedterm&lt;/P&gt;

&lt;P&gt;Which works, and provides true or false, but I would prefer "attr" or "opposite" (for the opposite of attr). &lt;/P&gt;

&lt;P&gt;| expr if(global.container.attr==true, "attr", "opposite")  | strcat  otherterm " " global.container.attr combinedterm | ... | stats count  by combinedterm &lt;BR /&gt;
would always equal 'opposite'. &lt;/P&gt;

&lt;P&gt;What I found would work was to rename before hand..&lt;/P&gt;

&lt;P&gt;|  rename global.container.attr AS tmp | expr if(tmp==true, "attr", "opposite") | .... (and so on). &lt;/P&gt;

&lt;P&gt;this might help someone else, and there may be a better way.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 15:26:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-on-JSON-data/m-p/194722#M56152</guid>
      <dc:creator>janoonan</dc:creator>
      <dc:date>2015-03-25T15:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval on JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-on-JSON-data/m-p/194723#M56153</link>
      <description>&lt;P&gt;do like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rename global.container.* AS  * | eval attr= if(attr==true, "attr", "opposite") |....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;then you can use like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;....| rename global.container.* AS  * | eval attr= if(attr==true, "attr", "opposite") | stats count by attr
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2015 17:10:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-on-JSON-data/m-p/194723#M56153</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2015-03-25T17:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval on JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-on-JSON-data/m-p/194724#M56154</link>
      <description>&lt;P&gt;Since, you field name contains special character, in EVAL statements, you need to enclose it within single quotes. This should work fine for you.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| expr if('global.container.attr'==true, "attr", "opposite") | strcat otherterm " " global.container.attr combinedterm | ... | stats count by combinedterm 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2015 17:17:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-on-JSON-data/m-p/194724#M56154</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-03-25T17:17:41Z</dc:date>
    </item>
  </channel>
</rss>

