<?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 create multiple reports/pdf output from a single search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-reports-pdf-output-from-a-single-search/m-p/400549#M116053</link>
    <description>&lt;P&gt;hi folks, we got a requirement to create xx number of reports based on a filter. &lt;BR /&gt;
For example the lookup file has filter of team&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TeamName,sourcetype
Windows,windows:*
Unix,syslog
Oracle,oracle*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We have a single search to grab the data , but based on the lookup, I need to xx reports based on TeamName Split the PDF/report within the result. So while sending, it needs to be in xx reports (3 in above case).  &lt;CODE&gt;Windows.pdf, unix.pdf, Oracle.pdf&lt;/CODE&gt; and so on&lt;/P&gt;

&lt;P&gt;Is it possible to do? Or do we need xx number of searches to do this?  (please note, our requirement is about 70 such groups which makes it 70 individual searches otherwise)&lt;/P&gt;</description>
    <pubDate>Sat, 06 Apr 2019 20:39:31 GMT</pubDate>
    <dc:creator>koshyk</dc:creator>
    <dc:date>2019-04-06T20:39:31Z</dc:date>
    <item>
      <title>How to create multiple reports/pdf output from a single search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-reports-pdf-output-from-a-single-search/m-p/400549#M116053</link>
      <description>&lt;P&gt;hi folks, we got a requirement to create xx number of reports based on a filter. &lt;BR /&gt;
For example the lookup file has filter of team&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TeamName,sourcetype
Windows,windows:*
Unix,syslog
Oracle,oracle*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We have a single search to grab the data , but based on the lookup, I need to xx reports based on TeamName Split the PDF/report within the result. So while sending, it needs to be in xx reports (3 in above case).  &lt;CODE&gt;Windows.pdf, unix.pdf, Oracle.pdf&lt;/CODE&gt; and so on&lt;/P&gt;

&lt;P&gt;Is it possible to do? Or do we need xx number of searches to do this?  (please note, our requirement is about 70 such groups which makes it 70 individual searches otherwise)&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2019 20:39:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-reports-pdf-output-from-a-single-search/m-p/400549#M116053</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2019-04-06T20:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple reports/pdf output from a single search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-reports-pdf-output-from-a-single-search/m-p/400550#M116054</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/221196"&gt;@koshyk&lt;/a&gt; can you try the following&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup team_data.csv
| map maxsearches=100 search="| tstats count where index=_internal AND sourcetype IN ("$sourcetype$") by sourcetype
| eval emailFieldForTest=\"$email$\"
| sendemail to=\"$email$\" format=\"html\" server=smtp.abc.com:123 use_tls=1 subject=\"Alert for $TeamName$\" message=\"This is an alert for $TeamName$\" sendpdf=true"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The search query returns result only sourcetype for specific team at a time. The &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Sendemail" target="_blank"&gt;sendemail&lt;/A&gt; command uses &lt;CODE&gt;$email$&lt;/CODE&gt; passed through &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Map" target="_blank"&gt;map&lt;/A&gt; command.&lt;/P&gt;

&lt;P&gt;PS: You can remove sendemail command to test whether &lt;CODE&gt;emailFieldForTest&lt;/CODE&gt; is being populated with correct email or not. When you get this to working you can get rid of &lt;CODE&gt;emailFieldForTest&lt;/CODE&gt; field.&lt;/P&gt;

&lt;P&gt;Team data for above example is based on Splunk's _internal index which prepares the lookup similar to yours for &lt;CODE&gt;splunkd, access and mongodb&lt;/CODE&gt; sourcetypes in Splunk's &lt;CODE&gt;_internal&lt;/CODE&gt; index.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| fields - _time
| eval data="splunkd,splunkd,splunkd_support@somewhere.com;access,*access*,access_support@somewhere.com;mongodb,mongodb,mongodb_support@somewhere.com"
| makemv data delim=";"
| mvexpand data
| makemv data delim=","
| eval TeamName=mvindex(data,0),sourcetype=mvindex(data,1),email=mvindex(data,2)
| table TeamName sourcetype email
| outputlookup team_data.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:58:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-reports-pdf-output-from-a-single-search/m-p/400550#M116054</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T23:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple reports/pdf output from a single search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-reports-pdf-output-from-a-single-search/m-p/400551#M116055</link>
      <description>&lt;P&gt;thank you mate. I've got the idea. will accept it.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2019 16:24:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-multiple-reports-pdf-output-from-a-single-search/m-p/400551#M116055</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2019-04-07T16:24:43Z</dc:date>
    </item>
  </channel>
</rss>

