<?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: Define a field and get an integer value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Define-a-field-and-get-an-integer-value/m-p/649972#M224724</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258534"&gt;@dnikam&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You could try the following :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| &amp;lt;you_base_search&amp;gt;
| rex field=&amp;lt;field_where_you_have_your_numerical_info&amp;gt; "^\D*(?&amp;lt;Field1&amp;gt;\d*)\/(?&amp;lt;Field2&amp;gt;\d*)"
| eval ratio=Field2/Field1
| fields ratio, Field1, Field2
| where ratio &amp;gt; 0.8&lt;/LI-CODE&gt;&lt;P&gt;&lt;EM&gt;If you run this search, it will &lt;STRONG&gt;display an event only if the ratio is actually above 0.8&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;You can simply click on the "save as" button, choose alert and complete the other info, be sure to trigger the alert when the number of results is greater than zero, and select the correct schedule time, for instance :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GaetanVP_0-1689076641310.png" style="width: 618px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/26204iD82F866447C4A6A6/image-dimensions/618x656?v=v2" width="618" height="656" role="button" title="GaetanVP_0-1689076641310.png" alt="GaetanVP_0-1689076641310.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hope it helps !&lt;BR /&gt;GaetanVP&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2023 11:57:45 GMT</pubDate>
    <dc:creator>GaetanVP</dc:creator>
    <dc:date>2023-07-11T11:57:45Z</dc:date>
    <item>
      <title>Define a field and get an integer value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Define-a-field-and-get-an-integer-value/m-p/649910#M224696</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a log file that do not conform to the log4j standards.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log file entry is as&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some text before. Mem=500/300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to write a script and get value of Field1=500 and Field2=300.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then compute Field1 and Field2 (For. e.g Field2/Field1 &amp;gt; 0.8), then trigger an alert.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any help on how this can be achieved.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 23:19:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Define-a-field-and-get-an-integer-value/m-p/649910#M224696</guid>
      <dc:creator>dnikam</dc:creator>
      <dc:date>2023-07-10T23:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Define a field and get an integer value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Define-a-field-and-get-an-integer-value/m-p/649912#M224697</link>
      <description>&lt;P&gt;No script is necessary.&amp;nbsp; It can be done within your query like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
| rex "Mem=(?&amp;lt;Field1&amp;gt;\d+)\/(?&amp;lt;Field2&amp;gt;\d+)"
| eval ratio=exact(Field2/Field1)
| where ratio&amp;gt;0.8&lt;/LI-CODE&gt;&lt;P&gt;Have the alert trigger when the number of results is not zero.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 00:13:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Define-a-field-and-get-an-integer-value/m-p/649912#M224697</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-07-11T00:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Define a field and get an integer value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Define-a-field-and-get-an-integer-value/m-p/649972#M224724</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258534"&gt;@dnikam&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You could try the following :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| &amp;lt;you_base_search&amp;gt;
| rex field=&amp;lt;field_where_you_have_your_numerical_info&amp;gt; "^\D*(?&amp;lt;Field1&amp;gt;\d*)\/(?&amp;lt;Field2&amp;gt;\d*)"
| eval ratio=Field2/Field1
| fields ratio, Field1, Field2
| where ratio &amp;gt; 0.8&lt;/LI-CODE&gt;&lt;P&gt;&lt;EM&gt;If you run this search, it will &lt;STRONG&gt;display an event only if the ratio is actually above 0.8&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;You can simply click on the "save as" button, choose alert and complete the other info, be sure to trigger the alert when the number of results is greater than zero, and select the correct schedule time, for instance :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GaetanVP_0-1689076641310.png" style="width: 618px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/26204iD82F866447C4A6A6/image-dimensions/618x656?v=v2" width="618" height="656" role="button" title="GaetanVP_0-1689076641310.png" alt="GaetanVP_0-1689076641310.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hope it helps !&lt;BR /&gt;GaetanVP&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 11:57:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Define-a-field-and-get-an-integer-value/m-p/649972#M224724</guid>
      <dc:creator>GaetanVP</dc:creator>
      <dc:date>2023-07-11T11:57:45Z</dc:date>
    </item>
  </channel>
</rss>

