<?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: Can you help me use start and end times in one search in a mapped subsearch? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395955#M114948</link>
    <description>&lt;P&gt;It was a typo, but the query still doesn't work with your line 2 suggestion. Any thoughts?&lt;/P&gt;</description>
    <pubDate>Mon, 25 Feb 2019 13:24:29 GMT</pubDate>
    <dc:creator>baklimek</dc:creator>
    <dc:date>2019-02-25T13:24:29Z</dc:date>
    <item>
      <title>Can you help me use start and end times in one search in a mapped subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395953#M114946</link>
      <description>&lt;P&gt;I'm trying to connect the sum of measurements from a certain process and connect them to workorders by the times the orders are in place. &lt;/P&gt;

&lt;P&gt;However, when I attempt to map the data using $StartTime$ and $EndTime$, the statistics table disappears and will not even show the fields from my first search. What am I doing wrong? The Start and EndTimes are in epoch time for the first part of the search. &lt;/P&gt;

&lt;P&gt;My search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="all_usf_hardsurfaces_orderhistory" TargetOrg="XX" MachineName="YXD12" (Status="IP") 
| stats values(_time) as StartTime by WorkOrderNumber, MaterialName, _time, Quantity
| eval Qty=round(Quantity,0)
| fields  StartTime EndTime WorkOrderNumber MaterialName Qty
| sort by -StartTime
| delta _time as DeltaStart
| eval DeltaStart=abs(DeltaStart)
| eval EndTime=_time+DeltaStart
| fields Time EndTime WorkOrderNumber MaterialName Qty
|map search="search index=pltxx_da ProcessName="Defecting" ItemName="Current Length Output (No Waste)" earliest=$StartTime$ latest=$EndTime$  
|dedup Measurement consecutive=true |stats sum(Measurement) as Measurment |eval Measurement=Measurement/304.8"
|table StartTime EndTime WorkOrderNumber MaterialName Measurement
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Feb 2019 21:31:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395953#M114946</guid>
      <dc:creator>baklimek</dc:creator>
      <dc:date>2019-02-22T21:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me use start and end times in one search in a mapped subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395954#M114947</link>
      <description>&lt;P&gt;@baklimek,&lt;BR /&gt;
Two observations from your search.&lt;BR /&gt;
Line : 2 - values(_time) as StartTime could be a multivalue field since you are using &lt;CODE&gt;values&lt;/CODE&gt;. To make sure there is only one value, try &lt;CODE&gt;eval StartTime =mvindex(StartTime ,0)&lt;/CODE&gt; after the stats&lt;/P&gt;

&lt;P&gt;Line : 9 , You have a field &lt;CODE&gt;Time&lt;/CODE&gt; but not StartTime . Probably it's a typo but worth to check&lt;/P&gt;</description>
      <pubDate>Sat, 23 Feb 2019 05:27:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395954#M114947</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-02-23T05:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me use start and end times in one search in a mapped subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395955#M114948</link>
      <description>&lt;P&gt;It was a typo, but the query still doesn't work with your line 2 suggestion. Any thoughts?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 13:24:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395955#M114948</guid>
      <dc:creator>baklimek</dc:creator>
      <dc:date>2019-02-25T13:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me use start and end times in one search in a mapped subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395956#M114949</link>
      <description>&lt;P&gt;For one thing, I am pretty sure StartTime EndTime WorkOrderNumber MaterialName are empty after your mapped search.&lt;/P&gt;

&lt;P&gt;See: &lt;CODE&gt;| makeresults | eval foo="1;2;3" | makemv delim=";" foo | mvexpand foo | map search="makeresults | eval bar=$foo$"&lt;/CODE&gt;&lt;BR /&gt;
- you'll only have bar in the end, not the field foo defined before the mapped search.&lt;/P&gt;

&lt;P&gt;The other thing, playing with it and data that does not correlate to your specific use case at all, I noticed I had an empty EndTime in my first row of the input table to the map command, preventing it to run at all. After I added &lt;CODE&gt;where EndTime&amp;gt;StartTime&lt;/CODE&gt; before the map command, I at least got a table with Measurement calculated.&lt;/P&gt;

&lt;P&gt;Hth,&lt;BR /&gt;
-Kai.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 13:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395956#M114949</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2019-02-25T13:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me use start and end times in one search in a mapped subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395957#M114950</link>
      <description>&lt;P&gt;I'm a tad unfamiliar to the makeresults command (I'm newer to Splunk). Would the entire string be placed at the beginning? And how exactly would this help the values in StartTime, EndtTime, WorkOrderNumber, and MaterialName carry over?&lt;/P&gt;

&lt;P&gt;I appreciate your help!!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 17:37:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395957#M114950</guid>
      <dc:creator>baklimek</dc:creator>
      <dc:date>2019-02-25T17:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me use start and end times in one search in a mapped subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395958#M114951</link>
      <description>&lt;P&gt;I haven't added in the makeresults yet, but I have gotten the search to work. You are correct in the fact that the fields from the base search do not show up, only the searched field from the mapped search.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 19:04:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395958#M114951</guid>
      <dc:creator>baklimek</dc:creator>
      <dc:date>2019-02-25T19:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me use start and end times in one search in a mapped subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395959#M114952</link>
      <description>&lt;P&gt;Oh, don't bother with the &lt;CODE&gt;makeresults&lt;/CODE&gt; example. That should just be a oneliner to show how map works: It doesn't add events or statistics to your existing data, it's like a new search where you provided the input parameters.&lt;/P&gt;

&lt;P&gt;You will often answers here that work with &lt;CODE&gt;makeresults&lt;/CODE&gt; to provide a cut &amp;amp; paste example that works everywhere, just for conveniance. Since we all don't share a common data set, we often generate artificial data for a search, and &lt;CODE&gt;makeresults&lt;/CODE&gt; comes in handy to execute the search.&lt;/P&gt;

&lt;P&gt;If you need the fields that were available before the map command, I guess you could just add them inside the map like &lt;CODE&gt;eval Measurement=Measurement/304.8, StartTime=$StartTime$, EndTime=$EndTime$, WorkOrderNumber=$WorkOrderNumber$...&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 14:09:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395959#M114952</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2019-02-26T14:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me use start and end times in one search in a mapped subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395960#M114953</link>
      <description>&lt;P&gt;Your main mistake was not escaping the double-quotes inside of your &lt;CODE&gt;map&lt;/CODE&gt; string.  You also may not have a full understanding of what &lt;CODE&gt;map&lt;/CODE&gt; does and how it works based on how you are handling the fields.  I have made many assumptions to guess what you are trying to do.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="all_usf_hardsurfaces_orderhistory" TargetOrg="XX" MachineName="YXD12" (Status="IP") 
| stats values(_time) as StartTime by WorkOrderNumber, MaterialName, _time, Quantity 
| eval Qty=round(Quantity,0) 
| fields StartTime EndTime WorkOrderNumber MaterialName Qty 
| sort by -StartTime 
| delta _time as DeltaStart 
| eval DeltaStart=abs(DeltaStart) 
| eval EndTime=_time+DeltaStart 
| fields StartTime EndTime WorkOrderNumber MaterialName Qty 
| map search="search index=pltxx_da ProcessName=\"Defecting\" ItemName=\"Current Length Output (No Waste)\" earliest=$StartTime$ latest=$EndTime$  
   |dedup Measurement consecutive=true
   | stats sum(Measurement) as Measurment
   | eval Measurement=Measurement/304.8, StartTime=$StartTime$, EndTime=$EndTime$, WorkOrderNumber=$WorkOrderNumber$, MaterialName=$MaterialName$, Qty=$Qty$" 
| table StartTime EndTime WorkOrderNumber MaterialName Measurement Qty
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Mar 2019 04:06:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395960#M114953</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-06T04:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me use start and end times in one search in a mapped subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395961#M114954</link>
      <description>&lt;P&gt;Also, both &lt;CODE&gt;StartTime&lt;/CODE&gt; and &lt;CODE&gt;EndTime&lt;/CODE&gt; must be &lt;CODE&gt;time_t&lt;/CODE&gt; (AKA &lt;CODE&gt;epoch&lt;/CODE&gt;, a number).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 04:07:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-use-start-and-end-times-in-one-search-in-a/m-p/395961#M114954</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-06T04:07:12Z</dc:date>
    </item>
  </channel>
</rss>

