<?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 Auto Resolving Pagerduty Alerts in #Random</title>
    <link>https://community.splunk.com/t5/Random/Auto-Resolving-Pagerduty-Alerts/m-p/504687#M1</link>
    <description>&lt;P&gt;Hey all.&lt;/P&gt;
&lt;P&gt;So there is this thing that I periodically trawl the web for and never seem to find any results.&lt;/P&gt;
&lt;P&gt;It's a small thing but a huge bug bear.&lt;/P&gt;
&lt;P&gt;I really wanted all of our pagerduty alerts using the app in splunk to autoresolve when the trigger had cleared.&lt;/P&gt;
&lt;P&gt;It looks like I may have come across a possible solution, and I wanted to see if anyone else has done this or found a better way. And to share in case I can help someone else.&lt;/P&gt;
&lt;P&gt;Today I finally managed to get this working, and the trick was a new feature in Pagerduty called Eventrules.&lt;/P&gt;
&lt;P&gt;Essentially you can create a an EventRuleset which will get you a new integration URL and key, and allow you to apply rules to non-standard fields in the payload.&lt;/P&gt;
&lt;P&gt;An example ruleset based on the following result payload would look like the following"&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"result": {

"routing_key":"your eventruleset routing key",

"dedup_key":"yourunique key, maybe the alert name",

"event_action":"trigger or resolve",

"severity":"critical or warning etc",

"summary":"some high level info",

"source":"usually the machine with a problem"

}

&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Your event rules then may look something like the below:&lt;/P&gt;
&lt;P&gt;if result.event_action=resolve then resolve the incident using the dedup key&lt;/P&gt;
&lt;P&gt;if result.event_action=trigger and result.severity=critical then severity is critical and raise new alert&lt;/P&gt;
&lt;P&gt;etc&lt;/P&gt;
&lt;P&gt;Now this does raise a small problem in that if your alert raises no rows then you won't be able to send the resolve.&lt;/P&gt;
&lt;P&gt;The below is extremely simple but does the job as an example by adding a stats count. The only caveat is that if you want an alert per event, you need to do some more work.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=_internal ERROR

| stats count as event_count

| eval dedup_key="ddddd"

| eval severity="warning"

| eval event_action=case(event_count&amp;gt;0,"trigger",1=1,"resolve")

| eval summary="A summary of this event"

| eval source="servera.example.com"

| eval routing_key="XXXXXXXXX"

| table dedup_key,severity,event_action, summary, source, routing_key

&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;All that's required after this is to update your integration url to use the eventrules api and key.&lt;/P&gt;
&lt;P&gt;This can however be spammy, because an api call will be made every time the alert runs.&lt;/P&gt;
&lt;P&gt;To get past that I created a KVStore called state_event and do an outputlookup to it each time the event runs. The fields i record are _key=dedup_key, event_action, date_last_changed and date_last_run.&lt;/P&gt;
&lt;P&gt;In the pagerduty alert properties you can change the alert trigger to custom and set the search to "where event_action!=event_action_lookup".&lt;/P&gt;
&lt;P&gt;Now it will only fire if this runs event_action(trigger or resolve) is different from the last. This will reduce noise and allow for some stateful tracking of each alert if so desired.&lt;/P&gt;
&lt;P&gt;Below is an example of the code i put after the table * example above to handle the above logic:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;eval _key=dedup_key
| eval date_last_run=now()
| join type=left
[| inputlookup state_alert
| rename event_action AS event_action_lookup
| rename date_last_change AS date_last_change_lookup
| fields event_action_lookup, date_last_change_lookup]
| eval date_last_change=case(event_action!=event_action_lookup, now(),1=1,date_last_change_lookup)
| outputlookup state_alert append=true key_field=_key

&lt;/LI-CODE&gt;
&lt;P&gt;Hopefully someone finds this useful, can improve on it, or show me a better way &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 30 May 2024 23:13:23 GMT</pubDate>
    <dc:creator>jethrop</dc:creator>
    <dc:date>2024-05-30T23:13:23Z</dc:date>
    <item>
      <title>Auto Resolving Pagerduty Alerts</title>
      <link>https://community.splunk.com/t5/Random/Auto-Resolving-Pagerduty-Alerts/m-p/504687#M1</link>
      <description>&lt;P&gt;Hey all.&lt;/P&gt;
&lt;P&gt;So there is this thing that I periodically trawl the web for and never seem to find any results.&lt;/P&gt;
&lt;P&gt;It's a small thing but a huge bug bear.&lt;/P&gt;
&lt;P&gt;I really wanted all of our pagerduty alerts using the app in splunk to autoresolve when the trigger had cleared.&lt;/P&gt;
&lt;P&gt;It looks like I may have come across a possible solution, and I wanted to see if anyone else has done this or found a better way. And to share in case I can help someone else.&lt;/P&gt;
&lt;P&gt;Today I finally managed to get this working, and the trick was a new feature in Pagerduty called Eventrules.&lt;/P&gt;
&lt;P&gt;Essentially you can create a an EventRuleset which will get you a new integration URL and key, and allow you to apply rules to non-standard fields in the payload.&lt;/P&gt;
&lt;P&gt;An example ruleset based on the following result payload would look like the following"&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"result": {

"routing_key":"your eventruleset routing key",

"dedup_key":"yourunique key, maybe the alert name",

"event_action":"trigger or resolve",

"severity":"critical or warning etc",

"summary":"some high level info",

"source":"usually the machine with a problem"

}

&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Your event rules then may look something like the below:&lt;/P&gt;
&lt;P&gt;if result.event_action=resolve then resolve the incident using the dedup key&lt;/P&gt;
&lt;P&gt;if result.event_action=trigger and result.severity=critical then severity is critical and raise new alert&lt;/P&gt;
&lt;P&gt;etc&lt;/P&gt;
&lt;P&gt;Now this does raise a small problem in that if your alert raises no rows then you won't be able to send the resolve.&lt;/P&gt;
&lt;P&gt;The below is extremely simple but does the job as an example by adding a stats count. The only caveat is that if you want an alert per event, you need to do some more work.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=_internal ERROR

| stats count as event_count

| eval dedup_key="ddddd"

| eval severity="warning"

| eval event_action=case(event_count&amp;gt;0,"trigger",1=1,"resolve")

| eval summary="A summary of this event"

| eval source="servera.example.com"

| eval routing_key="XXXXXXXXX"

| table dedup_key,severity,event_action, summary, source, routing_key

&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;All that's required after this is to update your integration url to use the eventrules api and key.&lt;/P&gt;
&lt;P&gt;This can however be spammy, because an api call will be made every time the alert runs.&lt;/P&gt;
&lt;P&gt;To get past that I created a KVStore called state_event and do an outputlookup to it each time the event runs. The fields i record are _key=dedup_key, event_action, date_last_changed and date_last_run.&lt;/P&gt;
&lt;P&gt;In the pagerduty alert properties you can change the alert trigger to custom and set the search to "where event_action!=event_action_lookup".&lt;/P&gt;
&lt;P&gt;Now it will only fire if this runs event_action(trigger or resolve) is different from the last. This will reduce noise and allow for some stateful tracking of each alert if so desired.&lt;/P&gt;
&lt;P&gt;Below is an example of the code i put after the table * example above to handle the above logic:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;eval _key=dedup_key
| eval date_last_run=now()
| join type=left
[| inputlookup state_alert
| rename event_action AS event_action_lookup
| rename date_last_change AS date_last_change_lookup
| fields event_action_lookup, date_last_change_lookup]
| eval date_last_change=case(event_action!=event_action_lookup, now(),1=1,date_last_change_lookup)
| outputlookup state_alert append=true key_field=_key

&lt;/LI-CODE&gt;
&lt;P&gt;Hopefully someone finds this useful, can improve on it, or show me a better way &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 23:13:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Random/Auto-Resolving-Pagerduty-Alerts/m-p/504687#M1</guid>
      <dc:creator>jethrop</dc:creator>
      <dc:date>2024-05-30T23:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Resolving Pagerduty Alerts</title>
      <link>https://community.splunk.com/t5/Random/Auto-Resolving-Pagerduty-Alerts/m-p/689146#M1965</link>
      <description>&lt;P&gt;Awesome stuff! I reproduced your instructions in a step by step &lt;A title="guide" href="https://borisascode.com/blog/resolvable-splunk-alerts-pagerduty" target="_self"&gt;guide&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 22:04:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Random/Auto-Resolving-Pagerduty-Alerts/m-p/689146#M1965</guid>
      <dc:creator>borisascode</dc:creator>
      <dc:date>2024-05-30T22:04:20Z</dc:date>
    </item>
  </channel>
</rss>

