<?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 create multiple events with different values using makeresults in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668295#M229266</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248587"&gt;@djoobbani&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I find the simplest way to generate multiple events is a combination of makeresults, eval, and mvexpand:&lt;/P&gt;&lt;PRE&gt;| makeresults&lt;BR /&gt;| eval source="abc"&lt;BR /&gt;| eval msg="consumed"&lt;BR /&gt;| eval time_pairs=split("2023-11-09T21:33:05Z,2023-11-09T21:40:05Z|2023-11-09T21:34:05Z,2023-11-09T21:41:05Z|2023-11-09T21:35:05Z,2023-11-09T21:42:05Z", "|")&lt;BR /&gt;| mvexpand time_pairs&lt;BR /&gt;| eval time_pairs=split(time_pairs, ",")&lt;BR /&gt;| eval time_1=mvindex(time_pairs, 0), time_2=mvindex(time_pairs, 1)&lt;BR /&gt;| fields - time_pairs&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;You can also use streamstats count combined with eval case:&lt;/P&gt;&lt;PRE&gt;| makeresults count=3&lt;BR /&gt;| eval source="abc"&lt;BR /&gt;| eval msg="consumed"&lt;BR /&gt;| streamstats count&lt;BR /&gt;| eval time_1=case(count==1, "2023-11-09T21:33:05Z", count==2, "2023-11-09T21:34:05Z", count==3, "2023-11-09T21:35:05Z")&lt;BR /&gt;| eval time_2=case(count==1, "2023-11-09T21:40:05Z", count==2, "2023-11-09T21:41:05Z", count==3, "2023-11-09T21:42:05Z")&lt;BR /&gt;| fields - count&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;These are just two examples. You can be as creative as needed.&lt;/P&gt;</description>
    <pubDate>Sat, 11 Nov 2023 01:54:44 GMT</pubDate>
    <dc:creator>tscroggins</dc:creator>
    <dc:date>2023-11-11T01:54:44Z</dc:date>
    <item>
      <title>How to create multiple events with different values using makeresults</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668287#M229260</link>
      <description>&lt;P&gt;Hi there:&lt;/P&gt;&lt;P&gt;I have the following makeresults query:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;| makeresults count=3&lt;BR /&gt;| eval source="abc"&lt;BR /&gt;| eval msg="consumed"&lt;BR /&gt;| eval time_1="2023-11-09T21:33:05Z"&lt;BR /&gt;| eval time_2="2023-11-09T21:40:05Z"&lt;BR /&gt;&lt;BR /&gt;So i want to create three different events where the values for&amp;nbsp;time_1 &amp;amp;&amp;nbsp;time_2 are different for each event.&lt;BR /&gt;How can i do that?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 23:18:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668287#M229260</guid>
      <dc:creator>djoobbani</dc:creator>
      <dc:date>2023-11-10T23:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple events with different values using makeresults</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668295#M229266</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248587"&gt;@djoobbani&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I find the simplest way to generate multiple events is a combination of makeresults, eval, and mvexpand:&lt;/P&gt;&lt;PRE&gt;| makeresults&lt;BR /&gt;| eval source="abc"&lt;BR /&gt;| eval msg="consumed"&lt;BR /&gt;| eval time_pairs=split("2023-11-09T21:33:05Z,2023-11-09T21:40:05Z|2023-11-09T21:34:05Z,2023-11-09T21:41:05Z|2023-11-09T21:35:05Z,2023-11-09T21:42:05Z", "|")&lt;BR /&gt;| mvexpand time_pairs&lt;BR /&gt;| eval time_pairs=split(time_pairs, ",")&lt;BR /&gt;| eval time_1=mvindex(time_pairs, 0), time_2=mvindex(time_pairs, 1)&lt;BR /&gt;| fields - time_pairs&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;You can also use streamstats count combined with eval case:&lt;/P&gt;&lt;PRE&gt;| makeresults count=3&lt;BR /&gt;| eval source="abc"&lt;BR /&gt;| eval msg="consumed"&lt;BR /&gt;| streamstats count&lt;BR /&gt;| eval time_1=case(count==1, "2023-11-09T21:33:05Z", count==2, "2023-11-09T21:34:05Z", count==3, "2023-11-09T21:35:05Z")&lt;BR /&gt;| eval time_2=case(count==1, "2023-11-09T21:40:05Z", count==2, "2023-11-09T21:41:05Z", count==3, "2023-11-09T21:42:05Z")&lt;BR /&gt;| fields - count&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;These are just two examples. You can be as creative as needed.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Nov 2023 01:54:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668295#M229266</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2023-11-11T01:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple events with different values using makeresults</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668300#M229270</link>
      <description>&lt;P&gt;Thank you, how would i be able to reduce the result by only displaying the row with the earliest time (time_1 field)?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 11 Nov 2023 03:49:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668300#M229270</guid>
      <dc:creator>djoobbani</dc:creator>
      <dc:date>2023-11-11T03:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple events with different values using makeresults</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668319#M229275</link>
      <description>&lt;P&gt;You could just create one event instead of three, or in the example, just return the first event:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| head 1&lt;/LI-CODE&gt;
&lt;P&gt;If you're working with ISO time strings but unknown times in an unknown order, you can sort lexicographically:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| sort time_1
| head 1&lt;/LI-CODE&gt;
&lt;P&gt;If the time format is known but not necessarily in ISO format, you can convert time_1 to an epoch value using the appropriate format string (still ISO in this example) and sort the result:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval time_1_epoch=strptime(time_1, "%Y-%m-%dT%H:%M:%S%Z")
| sort time_1_epoch
| head 1&lt;/LI-CODE&gt;
&lt;P&gt;If multiple events have the same time_1 value, you can use eventstats and where:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval time_1_epoch=strptime(time_1, "%Y-%m-%dT%H:%M:%S%Z")
| eventstats min(time_1_epoch) as min_time_1
| where time_1_epoch==min_time_1&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 11 Nov 2023 16:54:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668319#M229275</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2023-11-11T16:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple events with different values using makeresults</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668321#M229276</link>
      <description>&lt;P&gt;Thank you very much for the solution!&lt;/P&gt;</description>
      <pubDate>Sat, 11 Nov 2023 15:48:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-events-with-different-values-using/m-p/668321#M229276</guid>
      <dc:creator>djoobbani</dc:creator>
      <dc:date>2023-11-11T15:48:05Z</dc:date>
    </item>
  </channel>
</rss>

