Sample action for PagerDuty (v1 Monitors)
Use Monitors to send alerts to PagerDuty by configuring a Webhook channel action. Incoming events from Observe trigger a new incident for a PagerDuty service, or grouped with alerts for an existing incident.
Requirements
To configure this integration, you need a PagerDuty admin account. If your login does not have the Admin base role, contact an Admin or Account Owner in your organization.
Integration tutorial
Begin by creating an integration in an existing PagerDuty service, or by creating a new service and integration.
In PagerDuty, create a service and integration
Create a new service and integration, or add an integration to an existing service. After you add the integration, record the integration key.
Create a new PagerDuty service and integration
To create a new service and integration, follow the instructions at Create a Service in the PagerDuty documentation, selecting Observe in the Integrations step.
After you create a new service and integration, be sure to record your integration key.
Add an integration to an existing PagerDuty service
Perform the following steps in PagerDuty to add an Observe integration to an existing service:
- Select Services > Service Directory.
- Click the name of the service you want to add the integration to.
- Select the Integrations tab for this service and click Add another integration.
- Enter an Integration Name in the format
monitoring-tool-service-name, such as Observe-K8s-Cluster. - In the Integration Type menu, select Observe.
- Click Add Integration to save the integration. PagerDuty redirects you to the Integrations tab for your service.
- Record your integration key.
Record your integration key
Go to your new or existing integration in PagerDuty and click the expand icon (). Record the integration key for the next step.
In Observe, create a shared action
After you have your PagerDuty integration key, return to Observe and complete the following steps:
-
From the left rail, open the Monitors pane.
-
Click Shared Actions.
-
Click Create Shared Action.
-
For Action Type, select PagerDuty.
-
In the URL field, enter the following URL:
https://events.pagerduty.com/v2/enqueue -
Accept the default Method of POST.
-
In Headers, add the following header:
Content-Type = application/json -
Paste the following template into the Body, replacing the default template:
{
"dedup_key":"{{notification.uuid}}",
"payload": {
"summary": "{{monitor.name}}: {{notification.description}}",
"timestamp": "{{notification.startTime}}",
"source": "Observe Kubernetes Environment",
"severity": "info",
"custom_details": {
"Observe Monitor": "{{monitor.name}}",
"Trigger at": "{{notification.startTime}}",
"Importance": "{{monitor.notifyWhenDetails.importance}}",
"Trigger Condition": "{{monitor.triggerWhen}}",
"Notification Condition": "{{monitor.notifyWhen}}",
{{#notification.hasValues}}
"Triggered_By": " {{#notification.valuesWithFieldName}} {{fieldName}}: {{#values}}{{.}}{{/values}},\n{{/notification.valuesWithFieldName}}",
{{/notification.hasValues}}
"Description": "{{notification.description}}",
{{#notification.resourcesWithLinkType}}
"{{linkType}}": "{{#instances}}{{name}}{{/instances}}",
{{/notification.resourcesWithLinkType}}
{{#notification.valuesByFieldName.scope}}
"Scope": "{{.}}",
{{/notification.valuesByFieldName.scope}}
{{#notification.valuesByFieldName.target}}
"Target": "{{.}}",
{{/notification.valuesByFieldName.target}}
"Profile": "high"
}
},
"routing_key": "ROUTING_KEY",
{{#notification.hasResources}}
"links": [
{{#notification.resources}}
{
"href": "{{url}}",
"text": "{{name}}"
},
{{/notification.resources}}
{
"href": "#",
"text": "End of List"
}
],
{{/notification.hasResources}}
"event_action":{{#notification.isNew}} "trigger"{{/notification.isNew}}{{#notification.isEnded}}"resolve"{{/notification.isEnded}},
"client": "Observe Notification Link",
"client_url": "{{notification.url}}"
}- Replace
ROUTING_KEYin the above template with your routing key, the integration key that you created earlier.
NoteYou may customize your payload, for details see Customize alert messages.
- Click Send Test Notification and verify there are no errors.
- (Optional) Select non-synthetic sample data by expanding the Sample Data and Preview section and changing the dropdown from Static Sample Data.
- Click Create Shared Action to save.
Auto-resolve PagerDuty Incidents
You may optionally configure an ending notification to automatically resolve a PagerDuty incident.
In Observe
To enable auto-resolving incidents, configure a new Webhook channel action:
- Edit an existing Shared Action, or create a new one following the steps in In Observe, create a shared action, above.
- Update the Body template to add a new key,
is_ended, incustom_details:When an incident is resolved and Observe sends an ended notification, the"custom_details": { "is_ended": "{{notification.isEnded}}", "Observe Monitor": "{{monitor.name}}", "Trigger at": "{{notification.startTime}}",is_endedkey triggers the PagerDuty auto-resolve event rule. - In the Delivery section, under Status Updates, enable Send update that notification has ended to generate a notification when the monitor condition has resolved.
In PagerDuty
-
Navigate to the Service Directory and select the service you wish to configure.
-
In the Service panel, select the Settings tab.
-
Under Event Management, click Basic Service Event Rules and then New Event Rule.
-
Under When events match these conditions, choose Custom Details from the dropdown and enter the
custom_detailsvalue you configured in Observe. Example:is_ended. -
In the second condition dropdown, select equals and enter the value
true.
-
Click Do these things to open the actions panel.
-
Click Advanced, check Set a custom trigger/resolve action and select Always resolve an alert.
-
Click Save Rule.
Test the auto-resolve rule
To test creating and resolving incidents:
- In Observe, open your channel action configuration and click Send Test New Notification.
- In PagerDuty, confirm a new incident was opened.
- In Observe, select Send Test Ended Notification from the dropdown next to the test notification button.
- In PagerDuty, confirm the incident was closed.
How to uninstall
Follow these steps to uninstall the PagerDuty Alert Channel from Observe:
- From the left navigation pane, open the Other pane by clicking "..."
- Under Alerting, click Shared Actions.
- Find the action you previously created.
- Click "..." to the right of the Shared Action and select Delete.
- Confirm by clicking Delete Shared Action.
Updated about 2 months ago