<?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 do stack multi search in a result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241931#M71977</link>
    <description>&lt;P&gt;Hello team,&lt;/P&gt;

&lt;P&gt;I'm a splunk beginner and i'm looking for a solution.&lt;/P&gt;

&lt;P&gt;My research is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="itsm_extract" Environement="Production" metier="Ass" groupe_proprietaire="MOE ASS FCT*" categorisation_produit_3="*ECH*" | eval _time=strptime(date_creation,"%d/%m/%Y") | eval RPTMois=strftime(_time, "%m") | eval Mois=strftime(_time, "%B") | stats count as "Total Incidents" by Mois,RPTMois | sort RPTMois | fields - RPTMois | append [search sourcetype="itsm_extract" Environement="Production" metier="Ass" groupe_proprietaire="PIL CC05 OPEN CIB IS RB N1" analyse_technique="Autre erreur batch" | fields + resume + date_creation | rex field=resume "(?:[A-Z0-9\-]*\_){4}[A-Z0-9]{2}(?&amp;lt;code_app&amp;gt;[A-Z0-9]{3})" | rex field=code_app "(?&amp;lt;car2&amp;gt;[A-Z0-9]{2})(?&amp;lt;car3&amp;gt;[A-Z0-9])" | eval code_app_final=if(isint(car3),car2,code_app) | join code_app_final [search sourcetype="ref_application" | fields + Code_Application,Affectation,Domaine | rename Code_Application as code_app_final] | eval _time=strptime(date_creation,"%d/%m/%Y") | eval RPTMois=strftime(_time, "%m") | eval Mois=strftime(_time, "%B") | search Domaine="*ECH*" | stats count(Domaine) as "Total Dysfonctionnements" by RPTMois,Mois | fields - RPTMois]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;image?&lt;IMG src="http://www.hostingpics.net/viewer.php?id=797097splunkanw.png" alt="splunk" /&gt;&lt;BR /&gt;
Link: &lt;A href="http://www.hostingpics.net/viewer.php?id=797097splunkanw.png"&gt;http://www.hostingpics.net/viewer.php?id=797097splunkanw.png&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;My question is: how should i do to merge my events by month in order to have only one occurence of each month? This way to be able to do a stacked histogram.&lt;/P&gt;

&lt;P&gt;I have tried append, appendcols, multisearch....&lt;/P&gt;

&lt;P&gt;Thank you for your help and sorry for this english.&lt;/P&gt;

&lt;P&gt;Kévin&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jan 2017 15:30:23 GMT</pubDate>
    <dc:creator>guilpink</dc:creator>
    <dc:date>2017-01-18T15:30:23Z</dc:date>
    <item>
      <title>How do stack multi search in a result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241931#M71977</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;

&lt;P&gt;I'm a splunk beginner and i'm looking for a solution.&lt;/P&gt;

&lt;P&gt;My research is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="itsm_extract" Environement="Production" metier="Ass" groupe_proprietaire="MOE ASS FCT*" categorisation_produit_3="*ECH*" | eval _time=strptime(date_creation,"%d/%m/%Y") | eval RPTMois=strftime(_time, "%m") | eval Mois=strftime(_time, "%B") | stats count as "Total Incidents" by Mois,RPTMois | sort RPTMois | fields - RPTMois | append [search sourcetype="itsm_extract" Environement="Production" metier="Ass" groupe_proprietaire="PIL CC05 OPEN CIB IS RB N1" analyse_technique="Autre erreur batch" | fields + resume + date_creation | rex field=resume "(?:[A-Z0-9\-]*\_){4}[A-Z0-9]{2}(?&amp;lt;code_app&amp;gt;[A-Z0-9]{3})" | rex field=code_app "(?&amp;lt;car2&amp;gt;[A-Z0-9]{2})(?&amp;lt;car3&amp;gt;[A-Z0-9])" | eval code_app_final=if(isint(car3),car2,code_app) | join code_app_final [search sourcetype="ref_application" | fields + Code_Application,Affectation,Domaine | rename Code_Application as code_app_final] | eval _time=strptime(date_creation,"%d/%m/%Y") | eval RPTMois=strftime(_time, "%m") | eval Mois=strftime(_time, "%B") | search Domaine="*ECH*" | stats count(Domaine) as "Total Dysfonctionnements" by RPTMois,Mois | fields - RPTMois]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;image?&lt;IMG src="http://www.hostingpics.net/viewer.php?id=797097splunkanw.png" alt="splunk" /&gt;&lt;BR /&gt;
Link: &lt;A href="http://www.hostingpics.net/viewer.php?id=797097splunkanw.png"&gt;http://www.hostingpics.net/viewer.php?id=797097splunkanw.png&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;My question is: how should i do to merge my events by month in order to have only one occurence of each month? This way to be able to do a stacked histogram.&lt;/P&gt;

&lt;P&gt;I have tried append, appendcols, multisearch....&lt;/P&gt;

&lt;P&gt;Thank you for your help and sorry for this english.&lt;/P&gt;

&lt;P&gt;Kévin&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 15:30:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241931#M71977</guid>
      <dc:creator>guilpink</dc:creator>
      <dc:date>2017-01-18T15:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do stack multi search in a result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241932#M71978</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="itsm_extract" Environement="Production" metier="Ass"
    groupe_proprietaire="MOE ASS FCT*" categorisation_produit_3="*ECH*"
| eval date_creation=strptime(date_creation,"%d/%m/%Y")
| eval RPTMois=strftime(date_creation, "%m")
| eval Mois=strftime(date_creation, "%B")
| stats count as "Total Incidents" by RPTMois Mois
| append [ search sourcetype="itsm_extract" Environement="Production" metier="Ass"
    groupe_proprietaire="PIL CC05 OPEN CIB IS RB N1" analyse_technique="Autre erreur batch"
    | fields + resume date_creation
    | rex field=resume "(?:[A-Z0-9\-]*\_){4}[A-Z0-9]{2}(?&amp;lt;code_app&amp;gt;[A-Z0-9]{3})"
    | rex field=code_app "(?&amp;lt;car2&amp;gt;[A-Z0-9]{2})(?&amp;lt;car3&amp;gt;[A-Z0-9])"
    | eval code_app_final=if(isint(car3),car2,code_app)
    | join code_app_final [ search sourcetype="ref_application"
        | fields + Code_Application Domaine
        | dedup Code_Application Domaine
        | rename Code_Application as code_app_final ]
    | eval date_creation=strptime(date_creation,"%d/%m/%Y")
    | eval RPTMois=strftime(date_creation, "%m")
    | eval Mois=strftime(date_creation, "%B")
    | search Domaine="*ECH*"
    | stats count as "Total Dysfonctionnements" by RPTMois Mois ]
| stats sum(*) as * by RPTMois Mois
| fields - RPTMois
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To be honest, the line that is probably most useful to you is the next-to-last line in the search, which collapses the data. I did rework a few things in the search. To be honest, I wanted to see if I could factor out at least one of the subsearches, but it was not possible based on my understanding of the data. But there are a few tweaks. I would avoid using the &lt;CODE&gt;_time&lt;/CODE&gt; field as it has the meaning of "the time of the event" in Splunk; you don't need an additional time field anyway.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 19:14:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241932#M71978</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2017-01-18T19:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do stack multi search in a result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241933#M71979</link>
      <description>&lt;P&gt;I started off with Iguinn's code, and then made some additional enhancements as follows:&lt;/P&gt;

&lt;P&gt;1) Since you don't use the value of date_creation except at the month level, I altered the value to pull only the year and month, then used that value instead of RptMois for all the summary stats.&lt;BR /&gt;
2) I didn't translate the month's long name (Mois) until the very end, because each RptMois has only one Mois, that was part of what was giving you your duplication problems.&lt;BR /&gt;
3) When I calculate the Mois, I also calculate the An, since there may be multiple years in your data at some point. &lt;BR /&gt;
4) I moved the test for Domaine like ECH inside the subsearch, which will kill the non-ECH records during the join itself,  a tiny bit earlier in the process.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="itsm_extract" Environement="Production" metier="Ass"
     groupe_proprietaire="MOE ASS FCT*" categorisation_produit_3="*ECH*"
 | eval date_creation=strptime(date_creation,"%d/%m/%Y")
 | eval date_creation=relative_time(date_creation, "@m")
 | stats count as "Total Incidents" by date_creation
 | append 
    [ search sourcetype="itsm_extract" Environement="Production" metier="Ass"
     groupe_proprietaire="PIL CC05 OPEN CIB IS RB N1" analyse_technique="Autre erreur batch"
     | fields + resume date_creation
     | rex field=resume "(?:[A-Z0-9\-]*\_){4}[A-Z0-9]{2}(?&amp;lt;code_app&amp;gt;[A-Z0-9]{3})"
     | rex field=code_app "(?&amp;lt;car2&amp;gt;[A-Z0-9]{2})(?&amp;lt;car3&amp;gt;[A-Z0-9])"
     | eval code_app_final=if(isint(car3),car2,code_app)
     | join code_app_final 
        [ search sourcetype="ref_application"
         | fields + Code_Application Domaine
         | dedup Code_Application Domaine
         | search Domaine="*ECH*"
         | rename Code_Application as code_app_final ]
     | eval date_creation=strptime(date_creation,"%d/%m/%Y")
     | eval date_creation=relative_time(date_creation, "@m")
     | stats count as "Total Dysfonctionnements" by date_creation]
 | stats sum(*) as * by date_creation
 | eval An = strftime(date_creation, "%Y")
 | eval Mois=strftime(date_creation, "%B")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jan 2017 01:00:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241933#M71979</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-01-19T01:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do stack multi search in a result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241934#M71980</link>
      <description>&lt;P&gt;....it might be better to rename the field date_creation to month_creation for future maintainers....&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype="itsm_extract" Environement="Production" metier="Ass"
      groupe_proprietaire="MOE ASS FCT*" categorisation_produit_3="*ECH*"
  | eval month_creation=relative_time(strptime(date_creation,"%d/%m/%Y"), "@m")
  | stats count as "Total Incidents" by month_creation
  | append 
     [ search sourcetype="itsm_extract" Environement="Production" metier="Ass"
      groupe_proprietaire="PIL CC05 OPEN CIB IS RB N1" analyse_technique="Autre erreur batch"
      | fields + resume date_creation
      | rex field=resume "(?:[A-Z0-9\-]*\_){4}[A-Z0-9]{2}(?&amp;lt;code_app&amp;gt;[A-Z0-9]{3})"
      | rex field=code_app "(?&amp;lt;car2&amp;gt;[A-Z0-9]{2})(?&amp;lt;car3&amp;gt;[A-Z0-9])"
      | eval code_app_final=if(isint(car3),car2,code_app)
      | join code_app_final 
         [ search sourcetype="ref_application"
          | fields + Code_Application Domaine
          | dedup Code_Application Domaine
          | search Domaine="*ECH*"
          | rename Code_Application as code_app_final ]
      | eval month_creation=relative_time(strptime(date_creation,"%d/%m/%Y"), "@m")
      | stats count as "Total Dysfonctionnements" by month_creation]
  | stats sum(*) as * by month_creation
  | eval An = strftime(month_creation, "%Y")
  | eval Mois=strftime(month_creation, "%B")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:28:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241934#M71980</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-09-29T12:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do stack multi search in a result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241935#M71981</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;

&lt;P&gt;Really good, the last one works perfectly, I'm just wondering why the &lt;CODE&gt;stats sum(*) as * by RPTMois Mois&lt;/CODE&gt;is needed. &lt;BR /&gt;
Is sum(X) not only to "Returns the sum of the values of the field X"?&lt;BR /&gt;
 What I understand is sum() add both values for "January" of the col "Total Dysfonctionnements".&lt;/P&gt;

&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 08:47:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241935#M71981</guid>
      <dc:creator>guilpink</dc:creator>
      <dc:date>2017-01-19T08:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do stack multi search in a result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241936#M71982</link>
      <description>&lt;P&gt;what &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sum(*) as * 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;means is "for each (numeric) field, sum its values and put the results back into the same field"&lt;/P&gt;

&lt;P&gt;So if you have fields a and b, then field a will contain the sum of all values of a; field b will contain the sum of all values of b. In this case, you are also using &lt;CODE&gt;by RPTMois Mois&lt;/CODE&gt; and there is only one value for each field for each month. So you could use &lt;CODE&gt;first (*) as * by RPTMois Mois&lt;/CODE&gt; in this search and it would work equally well.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:23:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241936#M71982</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2017-01-19T16:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do stack multi search in a result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241937#M71983</link>
      <description>&lt;P&gt;Ok, understood! Thank you for your help &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 07:34:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241937#M71983</guid>
      <dc:creator>guilpink</dc:creator>
      <dc:date>2017-01-20T07:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do stack multi search in a result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241938#M71984</link>
      <description>&lt;P&gt;Hi @guilpink - Looks like you have a few possible solutions to your question. If one of them provided a working solution, please don't forget to click "Accept" below the best answer to resolve this post. If you still need help, please leave a comment. And of course, don't forget to up-vote any answer/comment that was helpful. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 07:52:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-stack-multi-search-in-a-result/m-p/241938#M71984</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2017-01-20T07:52:22Z</dc:date>
    </item>
  </channel>
</rss>

