
I Tried Stopping Only Notifications While Keeping Two-Way Slack Communication Using notificationPolicy in AWS Ops Agent
This page has been translated by machine translation. View original
Hello. This is Takayama.
In my environment, I trigger AWS Ops Agent investigations from PagerDuty incidents.
This PagerDuty is also integrated with Slack, so when an incident occurs, a notification arrives in Slack, and the Ops Agent's investigation results are also posted to Slack.
Also, if you set up a two-way integration between Ops Agent and Slack, it's convenient because you can send questions like "Summarize the alert" directly from Slack to Ops Agent.
However, when Ops Agent's Slack integration is enabled, Ops Agent also posts to the Slack channel every time the investigation is updated.
If you send notifications from PagerDuty and posts from Ops Agent to the same Slack channel, the notifications get duplicated as shown below.

This time, I'll try using Ops Agent's notificationPolicy to stop notifications to Slack while keeping two-way communication with Slack enabled, leaving only the notifications from PagerDuty.
Summary first
- notificationPolicy is set for each Ops Agent integration target (Slack, Microsoft Teams, ServiceNow, PagerDuty, Dynatrace)
- Even if you turn off notifications for a Slack channel, two-way chat from Slack remains usable
- Note, however, that investigations started from Slack chat are not posted to a channel whose notifications are turned off
- If you filter by "Priority" in PagerDuty, incidents that don't match the condition are not written back to PagerDuty
What is notificationPolicy?
notificationPolicy is a setting that controls what Ops Agent posts to integration targets.
By default, Ops Agent posts investigation updates to all connected notification channels.
By changing notificationPolicy, you can customize notification conditions for each integration target.
The items that can be configured in notificationPolicy are as follows.
| Console item | Description | Applicable integration targets |
|---|---|---|
| "Notifications" | Turn posting on/off | All 5 |
| "Priority" | Priority of investigations to post | All 5 |
| "Exclude triage notifications" | Triage notifications to exclude | All 5 |
| "Source integration" | Integration target that started the investigation | Slack and Teams |
Notifications
When you turn "Notifications" off, investigation and mitigation updates, custom agent notifications, and triage notifications are no longer posted.
Chat in a two-way Slack channel can still be used even if notifications are turned off.
However, investigations started from chat are not posted to a channel whose notifications are turned off.
Chat in a bidirectional Slack or Microsoft Teams channel keeps working, but an investigation that you start from chat follows the channel's policy and doesn't post there.
日本語翻訳 :
Chat in a bidirectional Slack or Microsoft Teams channel continues to work. However, an investigation started from chat follows that channel's policy, so it is not posted to that channel.
Priority
"Priority" filters the investigations to post by priority.
If you set "Priority" on the ServiceNow, PagerDuty, or Dynatrace integration targets, you can filter the incidents or problems that are written back by priority.
The priority of an investigation is determined by the priority of the incident or problem that started the investigation.
The priority mapping for each integration target is as follows.
| Ops Agent priority | ServiceNow | PagerDuty | Dynatrace event category |
|---|---|---|---|
| Critical | 1 - Critical | P1 | AVAILABILITY |
| High | 2 - High | P2, or urgency is High | ERROR, SLOWDOWN, MONITORING_UNAVAILABLE |
| Medium | 3 - Moderate | P3 | RESOURCE_CONTENTION, CUSTOM_ALERT |
| Low | 4 - Low | P4, or urgency is Low | INFO |
| Minimal | 5 - Planning | P5 | None |
Source integration
"Source integration" filters the investigations posted to Slack and Teams channels by the integration target that started the investigation.
The filtering only applies to investigations started from an integration target.
Investigations started from the Ops Agent web app or chat have no originating integration target, so they are always posted even if "Source integration" is set.
For example, if you select only PagerDuty for "Source integration", investigations started from PagerDuty and investigations started from chat or the web app are posted to the Slack channel, but investigations started from ServiceNow are not posted.
Let's try it
Checking the settings
On the Slack channel edit screen, you configure notificationPolicy in the "Notification policy" section.

The PagerDuty edit screen also has a "Notification policy" section, but it does not have "Source integration".

Trying turning off Slack notifications
Now let's actually turn off Slack notifications.
On the Slack channel edit screen, turn off "Notifications" under "Notification policy" and select "Next".

When turning off notifications, a confirmation popup appears, so if there's no problem, select "Turn off notifications".

After turning off notifications and triggering an incident, the only thing that arrived in Slack was the notification from PagerDuty.

Even with notifications turned off, two-way communication with the Slack channel is still enabled, so you can interact via chat.
When I mentioned Ops Agent in the thread of the PagerDuty notification and asked for an alarm summary, Ops Agent replied properly.
(Unlike replies within the thread of an Ops Agent Slack notification, the thread is not linked to the incident, so you need to specify the target alarm explicitly.)

Trying PagerDuty priority filtering
Since we're here, let's try filtering write-backs by priority with PagerDuty's notificationPolicy.
First, here is the incident before setting up the filter.
It's an incident with urgency High, and the investigation content from Ops Agent has been written back to Notes.

Next, on the PagerDuty edit screen, select "Critical" for "Priority" under "Notification policy" and apply the setting.
"Critical" corresponds to Ops Agent's Critical priority, which is PagerDuty's P1.
The previous incident had urgency High and was treated as equivalent to P2, so filtering to "Critical" means it will no longer be written back.

In this state, when I triggered an incident from the same alarm, it was no longer written back to Notes.

However, note that the Ops Agent investigation itself still runs behind the scenes, so this is not a feature that stops the investigation itself.
Conclusion
This time, I used Ops Agent's notificationPolicy to stop notifications to Slack and consolidate notifications in PagerDuty.
I also tried the setting that filters write-backs to PagerDuty by priority.
Even with Slack channel notifications turned off, chat from Slack remained usable as is.
When I filtered PagerDuty's "Priority" to "Critical", incidents with urgency High were no longer written back.
I was able to consolidate notifications in PagerDuty while still asking questions from Slack only when I want details, so I feel it became a setup that suits everyday operations.
I hope this is helpful for anyone who wants to control notifications using Ops Agent's notificationPolicy.
That's all from Takayama (@nyan_kotaroo).
