<?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 Why are we unable to evaluate a field obtained from rex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398328#M115537</link>
    <description>&lt;P&gt;Using below query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="incident" sourcetype="csv" | rex max_match=0 "(?(?i)(order))" | stats count by classification
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result I am getting is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;classification  count
ORDER   2
Order   120
order   83
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now i want to make this order value as 1 field value like&lt;/P&gt;

&lt;P&gt;Order 205&lt;/P&gt;

&lt;P&gt;And I trying to do this by converting classification field from string into numeric and then using eval function, but here tonumber function is not working. And I am not able to achieve the required result.&lt;/P&gt;

&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2019 17:55:54 GMT</pubDate>
    <dc:creator>nilbak1</dc:creator>
    <dc:date>2019-05-28T17:55:54Z</dc:date>
    <item>
      <title>Why are we unable to evaluate a field obtained from rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398328#M115537</link>
      <description>&lt;P&gt;Using below query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="incident" sourcetype="csv" | rex max_match=0 "(?(?i)(order))" | stats count by classification
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result I am getting is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;classification  count
ORDER   2
Order   120
order   83
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now i want to make this order value as 1 field value like&lt;/P&gt;

&lt;P&gt;Order 205&lt;/P&gt;

&lt;P&gt;And I trying to do this by converting classification field from string into numeric and then using eval function, but here tonumber function is not working. And I am not able to achieve the required result.&lt;/P&gt;

&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 17:55:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398328#M115537</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2019-05-28T17:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why are we unable to evaluate a field obtained from rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398329#M115538</link>
      <description>&lt;P&gt;I think, in your rex statement you may need to identify the field.&lt;/P&gt;

&lt;P&gt;| rex field=max_match&lt;/P&gt;

&lt;P&gt;But, I may be misunderstanding what you have.&lt;/P&gt;

&lt;P&gt;If you can provide a sample event I may be able to help more.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 18:12:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398329#M115538</guid>
      <dc:creator>jodyfsu</dc:creator>
      <dc:date>2019-05-28T18:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why are we unable to evaluate a field obtained from rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398330#M115539</link>
      <description>&lt;P&gt;yes i have used below in my query.  I am getting the same result.&lt;BR /&gt;
| rex max_match=0 field=_raw&lt;/P&gt;

&lt;P&gt;Sample Event I can't provide here.&lt;BR /&gt;
its just , not able to convert string to numeric, I have tried all options.&lt;BR /&gt;
Not sure, why eval function is not working after rex command&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:45:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398330#M115539</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2020-09-30T00:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why are we unable to evaluate a field obtained from rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398331#M115540</link>
      <description>&lt;P&gt;Use the &lt;CODE&gt;coalesce&lt;/CODE&gt; function to combine several fields into a single field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="incident" sourcetype="csv" | rex max_match=0 "(?(?i)(order))" | eval classification=coalesce(ORDER, Order, order) | stats count by classification
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2019 20:18:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398331#M115540</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-05-28T20:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why are we unable to evaluate a field obtained from rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398332#M115541</link>
      <description>&lt;P&gt;If your goal is to achieve the output as the sum of the count field irrespective of the case of the contents in the classification field i.e. "Order 205" as per your question then you can try an approach even without rex. Below is the code for the same. This will help you generalize the case of the contents of "Classification" field. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="incident" sourcetype="csv"
|eval Classification=lower(Classification)
|stats sum(Count) as Count by Classification
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2019 20:24:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398332#M115541</guid>
      <dc:creator>sayaksplunk</dc:creator>
      <dc:date>2019-05-28T20:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why are we unable to evaluate a field obtained from rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398333#M115542</link>
      <description>&lt;P&gt;I am getting no results found under statistics tab. Used below query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source="incident (1).csv" host="instance-3" index="incident" sourcetype="csv" | rex max_match=0 field=_raw "(?(?i)(order))" | eval classification=coalesce(ORDER, Order, order) |  stats count by classification
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 03:11:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398333#M115542</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2019-05-29T03:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Why are we unable to evaluate a field obtained from rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398334#M115543</link>
      <description>&lt;P&gt;Without rex it will not work here as I need to extract field different fields here from events then do their count.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 03:25:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398334#M115543</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2019-05-29T03:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why are we unable to evaluate a field obtained from rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398335#M115544</link>
      <description>&lt;P&gt;I have just modified your query, try if it works:&lt;/P&gt;

&lt;P&gt;source="incident (1).csv" host="instance-3" index="incident" sourcetype="csv"&lt;BR /&gt;
| rex max_match=0 field=_raw "(?(?i)(order))" | eval classification=coalesce("ORDER", "Order", "order") |  stats count by classification&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:43:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398335#M115544</guid>
      <dc:creator>sayaksplunk</dc:creator>
      <dc:date>2020-09-30T00:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why are we unable to evaluate a field obtained from rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398336#M115545</link>
      <description>&lt;P&gt;Its working now&lt;BR /&gt;
I have used below query. Thanks all for the help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    source="incident (1).csv" host="instance-3" index="incident" sourcetype="csv"
    | rex max_match=0 field=_raw "(?&amp;lt;classification&amp;gt;(?i)(order))" | eval classification=lower(classification)| stats count by classification
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 06:38:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-we-unable-to-evaluate-a-field-obtained-from-rex/m-p/398336#M115545</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2019-05-29T06:38:17Z</dc:date>
    </item>
  </channel>
</rss>

