<?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 extract a list and count over it? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164996#M46859</link>
    <description>&lt;P&gt;Try this, which should be identical but perform a bit better:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="raw_internet_cartonista" programa="ILCL" tipo="I" [ search index="raw_internet_cartonista" programa="WNHC" tipo="E" | dedup idlogon | field idlogon ] | stats dc(codigoAcesso) AS ClientesImpactados by info10 | sort 5 -ClientesImpactados
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it works, don't forget to "Accept" this answer.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jul 2015 14:22:44 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-07-08T14:22:44Z</dc:date>
    <item>
      <title>How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164986#M46849</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;

&lt;P&gt;I need help. I'm trying to do a search that extracts one list of Unique Session ID's and then performs with this list of ID's a count of User Agents in only one search. My log archive has the fields &lt;CODE&gt;tipo&lt;/CODE&gt; (type) equals to I=success, E=error, W=warning; &lt;CODE&gt;programa&lt;/CODE&gt; (transaction); &lt;CODE&gt;idlogon&lt;/CODE&gt; (session ID) and &lt;CODE&gt;info10&lt;/CODE&gt; (user agent).&lt;/P&gt;

&lt;P&gt;Now i have this search below that gives me a list of session ID's.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="raw_internet_cartonista" programa="WNHC" tipo="E" | eval Clientes=idlogon | dedup Clientes | table Clientes
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to perform a subsearch with this list of Clients and count the User Agent of each one.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="raw_internet_cartonista" programa="ILCL" tipo="I" | stats c as UserAgent by info10 (adding something to consider Clientes)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So i need to put these things together and return me some result. I've researched some commands like &lt;CODE&gt;map&lt;/CODE&gt;, &lt;CODE&gt;return&lt;/CODE&gt; and &lt;CODE&gt;lookup&lt;/CODE&gt; for doing this, but can't achieve any solution. &lt;/P&gt;

&lt;P&gt;I think that it should not be so difficult, but i can't find a way.&lt;BR /&gt;
Can anyone help me?&lt;/P&gt;

&lt;P&gt;Tks. Rgs.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 14:23:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164986#M46849</guid>
      <dc:creator>vitorvmiguel</dc:creator>
      <dc:date>2015-06-16T14:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164987#M46850</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="raw_internet_cartonista" programa="WNHC" tipo="E" | eval Clientes=idlogon | dedup Clientes | table Clientes | map search="search index=\"raw_internet_cartonista\" programa=\"ILCL\" tipo=\"I\" idlogon=$Clientes$| stats count as UserAgents by info10 idlogon"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2015 14:55:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164987#M46850</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-16T14:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164988#M46851</link>
      <description>&lt;P&gt;Or use a sub search as search condition in the main search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ index="raw_internet_cartonista" programa="WNHC" tipo="E" 
 | eval Clientes=idlogon 
 | dedup Clientes 
 | table Clientes ]
index="raw_internet_cartonista" programa="ILCL" tipo="I" | stats c as UserAgent by info10  Clientes
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the first [sub search] will return a list of conditions in the format ( Clientes="A" OR Clientes="B" OR Clientes="C" etc..)&lt;BR /&gt;
this will work if the field "Clientes" exists in the events of the main search.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 15:01:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164988#M46851</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2015-06-16T15:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164989#M46852</link>
      <description>&lt;P&gt;woodcock, query worked. But it's not counting how many Clients had used each UserAgent. The count is "1" for each entry. Can you help me with this?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 15:06:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164989#M46852</guid>
      <dc:creator>vitorvmiguel</dc:creator>
      <dc:date>2015-06-16T15:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164990#M46853</link>
      <description>&lt;P&gt;I cannot; the solution posted does EXACTLY what you asked PROVIDED that the 2nd search actually contains more than one event per pairing of &lt;CODE&gt;info10&lt;/CODE&gt; and &lt;CODE&gt;idlogon&lt;/CODE&gt;.  Because you have not said anything about what &lt;CODE&gt;info10&lt;/CODE&gt; is, we have no way to help you figure out what is going on there but I am sure that &lt;CODE&gt;info10&lt;/CODE&gt; is the problem.  Does it look "better" if we remove it?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="raw_internet_cartonista" programa="WNHC" tipo="E" | eval Clientes=idlogon | dedup Clientes | table Clientes | map search="search index=\"raw_internet_cartonista\" programa=\"ILCL\" tipo=\"I\" idlogon=$Clientes$| stats count as UserAgents by idlogon"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2015 15:15:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164990#M46853</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-16T15:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164991#M46854</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="raw_internet_cartonista" programa="WNHC" tipo="E" | stats list(idlogon ) as  Clientes|dedup Clientes|join[search  index="raw_internet_cartonista" programa="ILCL" tipo="I"|stats list(info10) as UserAgent  ]|stats count(Clientes) by UserAgent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 15:20:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164991#M46854</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-06-16T15:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164992#M46855</link>
      <description>&lt;P&gt;Sorry about my poor english, i'm trying to express myself the best i can.&lt;BR /&gt;
I'll try to explain again. My log information contains the fields tipo (type) equals to I=success, E=error, W=warning; programa (transaction); idlogon (session ID) and info10 (user agent). I'm trying to isolate in one list the Unique Client Sessions by colecting the idlogon.&lt;BR /&gt;
Then i wish to count how many Clients used wich UserAgent (info10) so i must get a list of how many Clients are facing errors in wich UserAgent. So my log information of UserAgent is in one transaction (programa="ILCL" tipo="I") and my error is in another transaction (programa="WNHC" tipo="E") so i need to put all this things together.&lt;BR /&gt;
First collect a list of clients facing error in the transaction, by extracting the session ID (idlogon), and after this use this list to count how many clients are using each different UserAgent.&lt;/P&gt;

&lt;P&gt;I hope i made myself clear. Sorry about my english again.&lt;BR /&gt;
Tks. Rgs&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 15:31:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164992#M46855</guid>
      <dc:creator>vitorvmiguel</dc:creator>
      <dc:date>2015-06-16T15:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164993#M46856</link>
      <description>&lt;P&gt;OK, based on your last clarification (re-translated as follows):&lt;/P&gt;

&lt;P&gt;My log information contains these fields:&lt;BR /&gt;
 - &lt;CODE&gt;tipo&lt;/CODE&gt; (type) = {I=success, E=error, W=warning}&lt;BR /&gt;
 - &lt;CODE&gt;programa&lt;/CODE&gt; (transaction)&lt;BR /&gt;
 - &lt;CODE&gt;idlogon&lt;/CODE&gt; (Client Session ID)&lt;BR /&gt;
 - &lt;CODE&gt;info10&lt;/CODE&gt; (User Agent)&lt;/P&gt;

&lt;P&gt;The end goal is to get a list of how many Clients ( &lt;CODE&gt;idlogon&lt;/CODE&gt;s ) are facing errors and in wich UserAgents ( &lt;CODE&gt;info10&lt;/CODE&gt; ).&lt;BR /&gt;
The problem is that the UserAgent ( &lt;CODE&gt;info10&lt;/CODE&gt; ) is in one transaction (programa="ILCL" tipo="I") but the error is in another transaction (programa="WNHC" tipo="E").&lt;/P&gt;

&lt;P&gt;First I need to gather Unique Client Sessions by collecting a list of distrinct &lt;CODE&gt;idlogon&lt;/CODE&gt; values.&lt;BR /&gt;
Then I need to count how many Clients ( &lt;CODE&gt;idlogon&lt;/CODE&gt;s ) used which UserAgent ( &lt;CODE&gt;info10&lt;/CODE&gt; ).&lt;/P&gt;

&lt;P&gt;If that is correct, then this will work (sticking with the original train of thought):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="raw_internet_cartonista" programa="WNHC" tipo="E" | dedup idlogon | map search="search index=\"raw_internet_cartonista\" programa=\"ILCL\" tipo=\"I\" idlogon=$Clientes$| stats dc(info10) AS NumUserAgentsWithErrors by idlogon"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, this should also work and be much quicker:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="raw_internet_cartonista" ((programa="WNHC" tipo="E") OR (programa="ILCL" tipo="I")) stats dc(info10) AS NumUserAgentsWithErrors values(info10) AS UserAgentsWithErrors dc(tipo) AS numTipos by idlogon | where numTipos=2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2015 16:05:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164993#M46856</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-16T16:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164994#M46857</link>
      <description>&lt;P&gt;So did this work?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 21:35:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164994#M46857</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-07T21:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164995#M46858</link>
      <description>&lt;P&gt;Hi woodcock, the query you've sent worked but didn't produced the results i expected. The query below produces the results i want, but the &lt;CODE&gt;join&lt;/CODE&gt; performance is realy bad.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="raw_internet_cartonista" programa="ILCL" tipo="I" |  join max=0 idlogon [search index="raw_internet_cartonista" programa="WNHC" tipo="E" ] | timechart span=1d dc(codigoAcesso) as ClientesImpactados by info10 | sort limit=5 by -ClientesImpactados
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So i was wondering if there is a way of doing the same job with better performance, the &lt;CODE&gt;map&lt;/CODE&gt; query you've sent me did not count any value, it simply shows one list of &lt;CODE&gt;info10&lt;/CODE&gt; and counts 1 for each.&lt;BR /&gt;
Anyway the both queries, mine and yours, seem to loose some values when compared to it running in parts.&lt;BR /&gt;
Do you have any hints? Any idea why? Or even a better performatic query to run besides that two? &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2015 12:42:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164995#M46858</guid>
      <dc:creator>vitorvmiguel</dc:creator>
      <dc:date>2015-07-08T12:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164996#M46859</link>
      <description>&lt;P&gt;Try this, which should be identical but perform a bit better:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="raw_internet_cartonista" programa="ILCL" tipo="I" [ search index="raw_internet_cartonista" programa="WNHC" tipo="E" | dedup idlogon | field idlogon ] | stats dc(codigoAcesso) AS ClientesImpactados by info10 | sort 5 -ClientesImpactados
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it works, don't forget to "Accept" this answer.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2015 14:22:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164996#M46859</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-08T14:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164997#M46860</link>
      <description>&lt;P&gt;I think you forgot something, because you are using multiple index in the same search and no function for subsearch. The query doesn't run.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2015 15:46:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164997#M46860</guid>
      <dc:creator>vitorvmiguel</dc:creator>
      <dc:date>2015-07-08T15:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164998#M46861</link>
      <description>&lt;P&gt;Yes, I forgot the &lt;CODE&gt;search&lt;/CODE&gt; directive; I have re-edited it; try again.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2015 15:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164998#M46861</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-08T15:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164999#M46862</link>
      <description>&lt;P&gt;Hi woodcock, i think we finally achieved the goal. Thanks for the help.&lt;BR /&gt;
Can you explain me the subsearch you've done &lt;CODE&gt;[ search index="raw_internet_cartonista" programa="WNHC" tipo="E" | dedup idlogon | fields idlogon ]&lt;/CODE&gt; mainly the &lt;CODE&gt;fields&lt;/CODE&gt; function, whats intended to do?&lt;/P&gt;

&lt;P&gt;Rgs.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2015 14:45:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/164999#M46862</guid>
      <dc:creator>vitorvmiguel</dc:creator>
      <dc:date>2015-07-13T14:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/165000#M46863</link>
      <description>&lt;P&gt;It keeps only that one &lt;CODE&gt;idlogon&lt;/CODE&gt; field so that the subsearch is expanded into a search directive for the outer search that looks like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... AND ((idlogon=a) OR (idlogon=b) OR (idlogon=c) OR ... OR (idlogon=z))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jul 2015 15:46:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/165000#M46863</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-13T15:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a list and count over it?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/165001#M46864</link>
      <description>&lt;P&gt;Many thanks woodcock. Now it makes sense to me. Rgs.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2015 16:57:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-list-and-count-over-it/m-p/165001#M46864</guid>
      <dc:creator>vitorvmiguel</dc:creator>
      <dc:date>2015-07-13T16:57:29Z</dc:date>
    </item>
  </channel>
</rss>

