<?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 How to get statistics from few rows with the same task id? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334387#M163347</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have few rows in 1 log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2018-01-25 13:49:40,107 INFO  [com.wss.service.agent.AgentServlet] (default task-46) ************************* Start handling request *************************
2018-01-25 13:49:40,107 INFO  [com.wss.service.agent.AgentServlet] (default task-46) coming from 10.10.10.10
2018-01-25 13:49:40,183 INFO  [com.wss.service.agent.AgentServlet] (default task-46) Handling request 
com.wss.service.agent.impl.AgentRequestParams@429a71c5[
  type=XXXX
  agent=QQQQ
  agentVersion=1.0
  pluginVersion=2.0
  domainToken=bc08304288fb47769288afdf9044ae0155hgg654
  product=ZZZZZ
  productVersion=3.0
  timestamp=Thu Jan 25 13:49:39 GMT+02:00 2018
  requesterEmail=splunk@ws.com
  projectInfos=AgentProjectInfo@2ae7c61a[coordinates= Coordinates@3f30d63a[groupId= null,artifactId= AAAAAAA,version= null ],parentCoordinates= null,projectToken= null ]
]
2018-01-25 13:49:40,183 INFO  [com.wss.service.agent.AgentServlet] (default task-46) request type is UPDATE
2018-01-25 13:49:40,228 INFO  [com.wss.service.agent.impl.AgentServiceImpl] (default task-46) updating domain: DomainName, product: ProductName
2018-01-25 13:49:40,266 DEBUG [com.wss.service.agent.impl.AgentServiceWorkManagerImpl] (default task-46) Updating inventory for BBBBBBB
2018-01-25 13:49:40,266 DEBUG [com.wss.service.agent.impl.AgentServiceWorkManagerImpl] (default task-46) New UpdateInventoryTask for DomainName
2018-01-25 13:49:40,266 DEBUG [com.wss.service.agent.AgentServlet] (default task-46) writing result
2018-01-25 13:49:40,267 INFO  [org.perf4j.TimingLogger] (default task-46) start[1516880980107] time[159] tag[Agent Request]
2018-01-25 13:49:40,267 INFO  [com.wss.service.agent.AgentServlet] (default task-46) ************************* Handling request finished *************************
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These rows describe a task (there are a lot of tasks with different types)&lt;BR /&gt;
The task has TaskID - 46 in this example&lt;BR /&gt;
How can we get a statistics on the tasks (how many times it was executed, duration, etc.) by type of task or agent&lt;/P&gt;

&lt;P&gt;Thanks for the help &lt;/P&gt;</description>
    <pubDate>Thu, 25 Jan 2018 12:04:28 GMT</pubDate>
    <dc:creator>niroren</dc:creator>
    <dc:date>2018-01-25T12:04:28Z</dc:date>
    <item>
      <title>How to get statistics from few rows with the same task id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334387#M163347</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have few rows in 1 log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2018-01-25 13:49:40,107 INFO  [com.wss.service.agent.AgentServlet] (default task-46) ************************* Start handling request *************************
2018-01-25 13:49:40,107 INFO  [com.wss.service.agent.AgentServlet] (default task-46) coming from 10.10.10.10
2018-01-25 13:49:40,183 INFO  [com.wss.service.agent.AgentServlet] (default task-46) Handling request 
com.wss.service.agent.impl.AgentRequestParams@429a71c5[
  type=XXXX
  agent=QQQQ
  agentVersion=1.0
  pluginVersion=2.0
  domainToken=bc08304288fb47769288afdf9044ae0155hgg654
  product=ZZZZZ
  productVersion=3.0
  timestamp=Thu Jan 25 13:49:39 GMT+02:00 2018
  requesterEmail=splunk@ws.com
  projectInfos=AgentProjectInfo@2ae7c61a[coordinates= Coordinates@3f30d63a[groupId= null,artifactId= AAAAAAA,version= null ],parentCoordinates= null,projectToken= null ]
]
2018-01-25 13:49:40,183 INFO  [com.wss.service.agent.AgentServlet] (default task-46) request type is UPDATE
2018-01-25 13:49:40,228 INFO  [com.wss.service.agent.impl.AgentServiceImpl] (default task-46) updating domain: DomainName, product: ProductName
2018-01-25 13:49:40,266 DEBUG [com.wss.service.agent.impl.AgentServiceWorkManagerImpl] (default task-46) Updating inventory for BBBBBBB
2018-01-25 13:49:40,266 DEBUG [com.wss.service.agent.impl.AgentServiceWorkManagerImpl] (default task-46) New UpdateInventoryTask for DomainName
2018-01-25 13:49:40,266 DEBUG [com.wss.service.agent.AgentServlet] (default task-46) writing result
2018-01-25 13:49:40,267 INFO  [org.perf4j.TimingLogger] (default task-46) start[1516880980107] time[159] tag[Agent Request]
2018-01-25 13:49:40,267 INFO  [com.wss.service.agent.AgentServlet] (default task-46) ************************* Handling request finished *************************
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These rows describe a task (there are a lot of tasks with different types)&lt;BR /&gt;
The task has TaskID - 46 in this example&lt;BR /&gt;
How can we get a statistics on the tasks (how many times it was executed, duration, etc.) by type of task or agent&lt;/P&gt;

&lt;P&gt;Thanks for the help &lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 12:04:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334387#M163347</guid>
      <dc:creator>niroren</dc:creator>
      <dc:date>2018-01-25T12:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to get statistics from few rows with the same task id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334388#M163348</link>
      <description>&lt;P&gt;Have a look at the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/transaction"&gt;transaction&lt;/A&gt; command. That should give you the tools you need to do what you want to do.&lt;/P&gt;

&lt;P&gt;For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...base search that returns these events...
| transaction TaskID startswith="Start handling request" endswith="Handling request finished"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The transactions that result from this will have a duration field, you can also append a stats command to this search to count number of transactions (by TaskID) etc.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 13:06:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334388#M163348</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-01-25T13:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to get statistics from few rows with the same task id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334389#M163349</link>
      <description>&lt;P&gt;Thanks for your answer, was extremely helpful.&lt;/P&gt;

&lt;P&gt;with this transaction, how can i find similar transactions that have a startwith="Start handling request" but dont have endswith (transaction that didnt finished yet.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Nir&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 07:50:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334389#M163349</guid>
      <dc:creator>niroren</dc:creator>
      <dc:date>2018-01-29T07:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get statistics from few rows with the same task id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334390#M163350</link>
      <description>&lt;P&gt;@niroren, for your case, you are better off running a stats command instead of transaction to perform the correlation:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;YourBaseSearch&amp;gt; "Start handling request" OR "Handling request finished"
| eval status=case(searchmatch("Start handling request"),"Start",searchmatch("Handling request finished"),"Finished")
| stats count as eventcount first(_time) as startTime last(_time) as endTime values(status) as status by TaskID
| eval duration=endTime-startTime
| fieldformat startTime=strftime(startTime,"%Y-%m-%d %H:%M:%S")
| fieldformat endTime=strftime(endTime,"%Y-%m-%d %H:%M:%S")
| search eventcount=1 AND status!="Finished"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Make sure TaskID is transaction ID and not something like Thread ID which may repeat over time, otherwise your search would need to be change to find correct matches.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 09:51:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334390#M163350</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-01-29T09:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to get statistics from few rows with the same task id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334391#M163351</link>
      <description>&lt;P&gt;You can leave out those startswith and endswith parts if needed.&lt;/P&gt;

&lt;P&gt;PS: you might want to change your 'answer' to a comment and if my answer (or the  answer of @niketnilay below) works for you, appreciated if you mark it as accepted, such that it is clear this question was answered &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 12:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistics-from-few-rows-with-the-same-task-id/m-p/334391#M163351</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-02-01T12:51:22Z</dc:date>
    </item>
  </channel>
</rss>

