<?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: MAP command query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/MAP-command-query/m-p/255295#M76450</link>
    <description>&lt;P&gt;Give this a try.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=pqr SERVICE_NAME=def |  transaction SERVICE_NAME startswith="WWW_REQ" endswith="WWW_RES" | sort _time |table ACCNO|map search="search index=abc sourcetype=pqr ACCNO=$ACCNO$ | rex "(?&amp;lt;precise_time&amp;gt;\d{8}T\d{6}\.\d{3})\" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%N") |  transaction SERVICE_NAME startswith="AAA_REQ" endswith="AAA_RES" | sort _time |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |table ACCNO,SERVICE_NAME,duration"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Updated Answer&lt;/STRONG&gt;&lt;BR /&gt;
Map is expensive and has limitation. Give this one a try. Also adding the &amp;gt;30 sec constraints that you mentioned (missing in question)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=pqr [search index=abc sourcetype=pqr SERVICE_NAME=def |  rex "(?&amp;lt;precise_time&amp;gt;\d{8}T\d{6}\.\d{3})" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%f") |  transaction SERVICE_NAME startswith="WWW_REQ" endswith="WWW_RES"  |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |search duration&amp;gt;30|table ACCNO] |  rex "(?&amp;lt;precise_time&amp;gt;\d{8}T\d{6}\.\d{3})" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%f") |  transaction SERVICE_NAME startswith="AAA_REQ" endswith="AAA_RES" | sort _time |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |table ACCNO,SERVICE_NAME,duration"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Jul 2016 15:50:55 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-07-14T15:50:55Z</dc:date>
    <item>
      <title>MAP command query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/MAP-command-query/m-p/255294#M76449</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;why I am not able to extract date from _raw in MAP command(second part of query)&lt;/P&gt;

&lt;P&gt;Below is my query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=pqr SERVICE_NAME=def |  rex "(?&amp;lt;precise_time&amp;gt;\d{8}T\d{6}\.\d{3})" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%f") |  transaction SERVICE_NAME startswith="WWW_REQ" endswith="WWW_RES" | sort _time |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |table ACCNO|map search="search index=abc sourcetype=pqr ACCNO=$ACCNO$ | rex "(?&amp;lt;precise_time&amp;gt;\d{8}T\d{6}\.\d{3})" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%f") |  transaction SERVICE_NAME startswith="AAA_REQ" endswith="AAA_RES" | sort _time |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |table ACCNO,SERVICE_NAME,duration"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If i remove rex part and duration in second query I am getting some results.But ultimately I need duration in my requirement. How to achieve this.&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;

&lt;P&gt;-PR&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 06:35:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/MAP-command-query/m-p/255294#M76449</guid>
      <dc:creator>mprreddy51</dc:creator>
      <dc:date>2016-07-14T06:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: MAP command query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/MAP-command-query/m-p/255295#M76450</link>
      <description>&lt;P&gt;Give this a try.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=pqr SERVICE_NAME=def |  transaction SERVICE_NAME startswith="WWW_REQ" endswith="WWW_RES" | sort _time |table ACCNO|map search="search index=abc sourcetype=pqr ACCNO=$ACCNO$ | rex "(?&amp;lt;precise_time&amp;gt;\d{8}T\d{6}\.\d{3})\" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%N") |  transaction SERVICE_NAME startswith="AAA_REQ" endswith="AAA_RES" | sort _time |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |table ACCNO,SERVICE_NAME,duration"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Updated Answer&lt;/STRONG&gt;&lt;BR /&gt;
Map is expensive and has limitation. Give this one a try. Also adding the &amp;gt;30 sec constraints that you mentioned (missing in question)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=pqr [search index=abc sourcetype=pqr SERVICE_NAME=def |  rex "(?&amp;lt;precise_time&amp;gt;\d{8}T\d{6}\.\d{3})" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%f") |  transaction SERVICE_NAME startswith="WWW_REQ" endswith="WWW_RES"  |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |search duration&amp;gt;30|table ACCNO] |  rex "(?&amp;lt;precise_time&amp;gt;\d{8}T\d{6}\.\d{3})" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%f") |  transaction SERVICE_NAME startswith="AAA_REQ" endswith="AAA_RES" | sort _time |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |table ACCNO,SERVICE_NAME,duration"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jul 2016 15:50:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/MAP-command-query/m-p/255295#M76450</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-14T15:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: MAP command query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/MAP-command-query/m-p/255296#M76451</link>
      <description>&lt;P&gt;@Somesh,&lt;/P&gt;

&lt;P&gt;In the first part of the search, we are taking "duration"&amp;gt;30sec&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=pqr SERVICE_NAME=def |  rex "(?\d{8}T\d{6}\.\d{3})" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%f") |  transaction SERVICE_NAME startswith="WWW_REQ" endswith="WWW_RES" | sort _time |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |table ACCNO,duration|search duration&amp;gt;30|table ACCNO

ACCNO     DURATION
1         31.22
2         34.89          (I am passing only ACCNO)
3         78.98
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This part of the search states that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=pqr ACCNO=$ACCNO$ | rex "(?\d{8}T\d{6}\.\d{3})" | eval precise_epoch=strptime(precise_time, "%Y%m%dT%H%M%S.%f") |  transaction SERVICE_NAME startswith="AAA_REQ" endswith="AAA_RES" | sort _time |  eval duration = tonumber(mvindex(precise_epoch, -1)) - tonumber(mvindex(precise_epoch, 0)) |table ACCNO,SERVICE_NAME,duration"

ACCNO   SERVICE_NAME     duration
1       a                0.89
        b                1.09
        c                2.45

2       e                4.67
        f                0.11
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This the output I am expecting.&lt;/P&gt;

&lt;P&gt;First I need to check in SERVICE_NAME=def with WWW_req and WWW_res  Account nos &amp;gt;30 sec &lt;BR /&gt;
second if any account number is greater than 30 then I need to find  for each accountnumber what are the services and time duration. I did it manually by copying one accno at a time,But there are 100's of accnos .By using MAP i am trying.&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:14:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/MAP-command-query/m-p/255296#M76451</guid>
      <dc:creator>mprreddy51</dc:creator>
      <dc:date>2020-09-29T10:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: MAP command query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/MAP-command-query/m-p/255297#M76452</link>
      <description>&lt;P&gt;Try the updated answer.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 19:23:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/MAP-command-query/m-p/255297#M76452</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-14T19:23:13Z</dc:date>
    </item>
  </channel>
</rss>

