<?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 do I make a custom alert message with variables? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438384#M174052</link>
    <description>&lt;P&gt;I'm glad you figured out an answer to your question @rbrisseyii. Would you mind accepting it so that others will know it's the correct solution?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 17 Dec 2018 21:47:30 GMT</pubDate>
    <dc:creator>mstjohn_splunk</dc:creator>
    <dc:date>2018-12-17T21:47:30Z</dc:date>
    <item>
      <title>How do I make a custom alert message with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438380#M174048</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have a search with several OR statements in it. Example, Microservice=this OR Microservice=that. When the search runs and emails me an alert, I currently have it set to "$result.Microservice$ with $job.resultCount$ alerts".&lt;/P&gt;

&lt;P&gt;In the text of the email, it only returned the name of the first Microservice, but gave me a total count of both This and That's events. &lt;/P&gt;

&lt;P&gt;I would like it to give me:&lt;BR /&gt;
"This" had x alerts &lt;BR /&gt;
"That" had y alerts&lt;/P&gt;

&lt;P&gt;Any suggestions to how I can have the email alert give me totals for each Microservice? I actually have a few more Microservices in my real search, I only listed 2 above.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 16:07:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438380#M174048</guid>
      <dc:creator>rbrisseyii</dc:creator>
      <dc:date>2018-12-17T16:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a custom alert message with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438381#M174049</link>
      <description>&lt;P&gt;Hi @rbrisseyii can you share your exact search?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 18:55:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438381#M174049</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2018-12-17T18:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a custom alert message with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438382#M174050</link>
      <description>&lt;P&gt;I will just provide the solution I was given through the Splunk Community Slack channel:&lt;/P&gt;

&lt;P&gt;| eventstats count as _toemail by Microservice SiteType | eval _toemail = Microservice . " " .  SiteType . " had " . _toemail . " alerts.\n" | eventstats values(_toemail) as _toemail | eval _toemail = mvjoin(_toemail, " ")&lt;/P&gt;

&lt;P&gt;which provides the following out put in email:&lt;BR /&gt;
microservice1 Prod had 336 alerts.&lt;BR /&gt;
microservice2 Prod had 23 alerts.&lt;BR /&gt;
microservice3 Prod had 5 alerts.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:25:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438382#M174050</guid>
      <dc:creator>rbrisseyii</dc:creator>
      <dc:date>2020-09-29T22:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a custom alert message with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438383#M174051</link>
      <description>&lt;P&gt;my search  | eventstats count as _toemail by Microservice SiteType | eval _toemail = Microservice . " " . SiteType . " had " . _toemail . " alerts.\n" | eventstats values(_toemail) as _toemail | eval _toemail = mvjoin(_toemail, " ")&lt;/P&gt;

&lt;P&gt;which provides the following out put in email:&lt;BR /&gt;
microservice1 Prod had 336 alerts.&lt;BR /&gt;
microservice2 Prod had 23 alerts.&lt;BR /&gt;
microservice3 Prod had 5 alerts.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:25:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438383#M174051</guid>
      <dc:creator>rbrisseyii</dc:creator>
      <dc:date>2020-09-29T22:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a custom alert message with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438384#M174052</link>
      <description>&lt;P&gt;I'm glad you figured out an answer to your question @rbrisseyii. Would you mind accepting it so that others will know it's the correct solution?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 21:47:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438384#M174052</guid>
      <dc:creator>mstjohn_splunk</dc:creator>
      <dc:date>2018-12-17T21:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a custom alert message with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438385#M174053</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/141083"&gt;@rbrisseyii&lt;/a&gt; what I tend to do in this situation is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my search
| stats count by Microservice SiteType
| eval Microservice_SiteType_count = MicroService + " " + SiteType + " = " + count + "alerts"
| stats values(Microservice_Sitetype_count) as Microservice_counts
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then I use &lt;CODE&gt;$result.Microservice_counts$&lt;/CODE&gt; in your alert&lt;/P&gt;

&lt;P&gt;You can format the eval however you like. &lt;/P&gt;

&lt;P&gt;The idea is you are creating field Microservice_SiteType_count for each Microservice SiteType pair&lt;BR /&gt;
And then finally you are looking at the values of all those pairs and you can grab it in your alert by using &lt;CODE&gt;$result.Microservice_counts$&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:29:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-make-a-custom-alert-message-with-variables/m-p/438385#M174053</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2020-09-29T22:29:42Z</dc:date>
    </item>
  </channel>
</rss>

