<?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: Need Help with spl query and Streamstats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/701058#M237840</link>
    <description>&lt;P&gt;You are right, I had issues in my raw data. Thanks very much for the help!!&lt;/P&gt;</description>
    <pubDate>Fri, 04 Oct 2024 20:46:30 GMT</pubDate>
    <dc:creator>807mohd</dc:creator>
    <dc:date>2024-10-04T20:46:30Z</dc:date>
    <item>
      <title>Need Help with spl query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/700927#M237793</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to achieve a result set which can be used in an alert later on.&lt;BR /&gt;&lt;BR /&gt;Basically when search is executed, its should look for field named "state" and evaluate with its value from two hours ago for the same corresponding record, which is field name "pv_number" and if the value of field did not change between "now" and "two hours ago", capture it as table showing previous state and current state along with previous time and current time.&lt;BR /&gt;&lt;BR /&gt;Any help is greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks much!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 16:11:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/700927#M237793</guid>
      <dc:creator>807mohd</dc:creator>
      <dc:date>2024-10-04T16:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with spl query and Streamstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/700954#M237803</link>
      <description>&lt;P&gt;I think streamstats in the title throw volunteers off because it is hard to see how it relates to your requirement, which you describe quite well without SPL. &amp;nbsp;It would be better if you also illustrate input and desired output.&lt;/P&gt;&lt;P&gt;Here is one way to do what you ask:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| index = foo sourcetype = bar earliest=-2h latest=now
| addinfo
| stats earliest(state) as two_hours_ago latest(state) as now by pv_number info_min_time info_max_time
| where two_hours_ago == now
| eval info_min_time = strftime(info_min_time, "%F %T"), info_max_time = strftime(info_max_time, "%F %T")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Emulated output without the where filter looks like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;pv_number&lt;/TD&gt;&lt;TD&gt;info_min_time&lt;/TD&gt;&lt;TD&gt;info_max_time&lt;/TD&gt;&lt;TD&gt;two_hours_ago&lt;/TD&gt;&lt;TD&gt;now&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ApplicationUpdateThread&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:44:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:44:19&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ExecProcessor&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:44:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:44:19&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HTTPDispatch&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:44:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:44:19&lt;/TD&gt;&lt;TD&gt;28&lt;/TD&gt;&lt;TD&gt;29&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SavedSearchFetcher&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:44:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:44:19&lt;/TD&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TcpChannelThread&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:44:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:44:19&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TelemetryMetricBuffer&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:44:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:44:19&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;indexerPipe&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:44:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:44:19&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;tailreader0&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:44:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:44:19&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;webui&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:44:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:44:19&lt;/TD&gt;&lt;TD&gt;28&lt;/TD&gt;&lt;TD&gt;29&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;With filter, the output is&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;pv_number&lt;/TD&gt;&lt;TD&gt;info_min_time&lt;/TD&gt;&lt;TD&gt;info_max_time&lt;/TD&gt;&lt;TD&gt;two_hours_ago&lt;/TD&gt;&lt;TD&gt;now&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ApplicationUpdateThread&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:42:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:42:19&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ExecProcessor&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:42:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:42:19&lt;/TD&gt;&lt;TD&gt;42&lt;/TD&gt;&lt;TD&gt;42&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SavedSearchFetcher&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:42:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:42:19&lt;/TD&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;indexerPipe&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:42:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:42:19&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;tailreader0&lt;/TD&gt;&lt;TD&gt;2024-10-03 22:42:19&lt;/TD&gt;&lt;TD&gt;2024-10-04 00:42:19&lt;/TD&gt;&lt;TD&gt;42&lt;/TD&gt;&lt;TD&gt;42&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Is this something you are looking for?&lt;/P&gt;&lt;P&gt;The emulation I use to produce mock data is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = _internal earliest=-2h latest=now
| rename thread_name as "pv_number", date_minute as state
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 00:49:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/700954#M237803</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-10-04T00:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with spl query and Streamstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/701013#M237825</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;yuanliu&lt;BR /&gt;&lt;BR /&gt;Firstly thanks for looking into it and helping with the SPL query.&amp;nbsp; It was pleasing to see someone responding I felt like I should buy a coffee &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;I apologize for my mistake of mentioning streamstats.&lt;BR /&gt;&lt;BR /&gt;I think i did not put my original request properly, let me try again.&lt;BR /&gt;so when the search is executed (now), we need data from two point in times, from now and two hours ago.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I'm running a search at 16:05:02, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;first set will have data values of pv_number (example ext034)&amp;nbsp; and "state" value (6) at that point-in-time&amp;nbsp; (from two hours ago, so 14:05:02)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the second set of data values,&amp;nbsp; pv_number (if its still exist in this point of time&amp;nbsp;@ 16:05:02) AND still has "state" value (6), then want to see the table showing pv_number and both times along with previous and current state.&lt;BR /&gt;&lt;BR /&gt;Hope It helps..&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 15:26:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/701013#M237825</guid>
      <dc:creator>807mohd</dc:creator>
      <dc:date>2024-10-04T15:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with spl query and Streamstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/701024#M237827</link>
      <description>&lt;P&gt;I think my understanding fits your description. &amp;nbsp;The idea behind my suggested search is:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Search between the two hours. &amp;nbsp;Find all records that has pv_number. (You can restrict pv_number to a given value but my search assumes that you want to group by pv_number, which is stated in the OP.)&lt;/LI&gt;&lt;LI&gt;Look for the earliest value of state, and the latest.&lt;/LI&gt;&lt;LI&gt;Compare earliest value and latest value. Only print those where the two equal.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Have you tried my search? &amp;nbsp;Also play with my emulation (that should run in any instance), and examine output with and without that where filter. &amp;nbsp;As my code indicates, I use thread_name to fake pv_number, date_minute to fake state. &amp;nbsp;They may have different values from your real data, but the principle is the same.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 16:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/701024#M237827</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-10-04T16:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with spl query and Streamstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/701058#M237840</link>
      <description>&lt;P&gt;You are right, I had issues in my raw data. Thanks very much for the help!!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 20:46:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-spl-query/m-p/701058#M237840</guid>
      <dc:creator>807mohd</dc:creator>
      <dc:date>2024-10-04T20:46:30Z</dc:date>
    </item>
  </channel>
</rss>

