Escalate incident in PagerDuty
Overview
This self service guide provides a comprehensive walkthrough on how to escalate incident in Pagerduty from Port using Port's self service actions.
Prerequisites
-
Port's GitHub app needs to be installed.
-
In your GitHub repository, go to Settings > Secrets and add the following secrets:
PAGERDUTY_API_KEY
- PagerDuty API token generated by the user.PORT_CLIENT_ID
- Your portclient id
How to get the credentials.PORT_CLIENT_SECRET
- Your portclient secret
How to get the credentials.
-
Optional - Install Port's PagerDuty integration learn more
PagerDuty IntegrationThis step is not required for this example, but it will create all the blueprint boilerplate for you, and also ingest and update the catalog in real time with your PagerDuty Incidents.
-
In Case you decided not to install the PagerDuty integration, you will need to create a blueprint for PagerDuty incidents in Port.
PagerDuty Incident Blueprint
{
"identifier": "pagerdutyIncident",
"description": "This blueprint represents a PagerDuty incident in our software catalog",
"title": "PagerDuty Incident",
"icon": "pagerduty",
"schema": {
"properties": {
"status": {
"type": "string",
"title": "Incident Status",
"enum": [
"triggered",
"annotated",
"acknowledged",
"reassigned",
"escalated",
"reopened",
"resolved"
]
},
"url": {
"type": "string",
"format": "url",
"title": "Incident URL"
},
"urgency": {
"type": "string",
"title": "Incident Urgency",
"enum": ["high", "low"]
},
"responder": {
"type": "string",
"title": "Assignee"
},
"escalation_policy": {
"type": "string",
"title": "Escalation Policy"
},
"created_at": {
"title": "Create At",
"type": "string",
"format": "date-time"
},
"updated_at": {
"title": "Updated At",
"type": "string",
"format": "date-time"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"pagerdutyService": {
"title": "PagerDuty Service",
"target": "pagerdutyService",
"required": false,
"many": true
}
}
}
GitHub Workflow
Create the file .github/workflows/escalate-incident.yaml
in the .github/workflows
folder of your repository.
We recommend creating a dedicated repository for the workflows that are used by Port actions.
GitHub Workflow
name: Escalate PagerDuty Incident
on:
workflow_dispatch:
inputs:
escalation_policy_id:
description: PagerDuty Escalation Policy ID to apply
required: true
type: string
urgency:
description: New urgency level for the incident (e.g., "high")
required: false
type: string
from:
description: The email address of a valid user associated with the account making the request.
required: true
type: string
port_context:
required: true
description: includes blueprint, run ID, and entity identifier from Port.
jobs:
escalate-incident:
runs-on: ubuntu-latest
steps:
- name: Inform execution of request to escalate incident
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_context).run_id}}
logMessage: "About to escalate incident in PagerDuty..."
- name: Escalate Incident in PagerDuty
id: escalate_incident
uses: fjogeleit/http-request-action@v1
with:
url: 'https://api.pagerduty.com/incidents/${{fromJson(inputs.port_context).entity}}'
method: 'PUT'
customHeaders: '{"Content-Type": "application/json", "Accept": "application/vnd.pagerduty+json;version=2", "Authorization": "Token token=${{ secrets.PAGERDUTY_API_KEY }}", "From": "${{ github.event.inputs.from }}"}'
data: >-
{
"incident": {
"type": "incident_reference",
"escalation_policy": {
"id": "${{ github.event.inputs.escalation_policy_id }}",
"type": "escalation_policy_reference"
},
"urgency": "${{ github.event.inputs.urgency }}"
}
}
- name: Inform PagerDuty request failure
if: failure()
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_context).run_id}}
logMessage: "Request to escalate incident failed ..."
- name: Inform ingestion of PagerDuty escalation to Port
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_context).run_id}}
logMessage: "Reporting the escalated incident back to Port ..."
- name: Upsert pagerduty entity to Port
id: upsert_entity
uses: port-labs/port-github-action@v1
with:
identifier: ${{inputs.entity_identifier}}
title: "${{ fromJson(steps.escalate_incident.outputs.response).incident.title }}"
blueprint: "pagerdutyIncident"
properties: |-
{
"status": "${{ fromJson(steps.escalate_incident.outputs.response).incident.status }}",
"url": "${{ fromJson(steps.escalate_incident.outputs.response).incident.self }}",
"urgency": "${{ fromJson(steps.escalate_incident.outputs.response).incident.urgency }}",
"responder": "${{ fromJson(steps.escalate_incident.outputs.response).incident.assignments[0].assignee.summary}}",
"escalation_policy": "${{ fromJson(steps.escalate_incident.outputs.response).incident.escalation_policy.summary }}",
"created_at": "${{ fromJson(steps.escalate_incident.outputs.response).incident.created_at }}",
"updated_at": "${{ fromJson(steps.escalate_incident.outputs.response).incident.updated_at }}"
}
relations: "${{ toJson(fromJson(inputs.port_context).relations) }}"
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: UPSERT
runId: ${{fromJson(inputs.port_context).run_id}}
- name: Inform Entity upsert failure
if: steps.upsert_entity.outcome == 'failure'
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_context).run_id}}
logMessage: "Failed to report the escalated incident back to Port ..."
- name: Inform completion of PagerDuty incident escalation
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_context).run_id}}
logMessage: "Incident escalation process was successful ✅"
Port Configuration
Create a new self service action using the following JSON configuration.
Escalate Incident In PagerDuty (click to expand)
Make sure to replace <GITHUB_ORG>
and <GITHUB_REPO>
with your GitHub organization and repository names respectively.
{
"identifier": "pagerdutyIncident_escalate_incident",
"title": "Escalate Incident",
"icon": "pagerduty",
"description": "Escalate a pagerduty incident",
"trigger": {
"type": "self-service",
"operation": "DAY-2",
"userInputs": {
"properties": {
"escalation_policy_id": {
"title": "Escalation Policy ID",
"description": "PagerDuty Escalation Policy ID to apply",
"icon": "pagerduty",
"type": "string"
},
"urgency": {
"icon": "pagerduty",
"title": "Urgency",
"description": "New urgency level for the incident (e.g., \"high\")",
"type": "string",
"default": "low",
"enum": [
"high",
"low"
],
"enumColors": {
"high": "orange",
"low": "lightGray"
}
},
"from": {
"icon": "User",
"title": "From",
"description": "The email address of a valid pagerduty user associated with the account making the request.",
"type": "string",
"format": "user"
}
},
"required": [
"escalation_policy_id",
"urgency",
"from"
],
"order": [
"escalation_policy_id",
"urgency",
"from"
]
},
"blueprintIdentifier": "pagerdutyIncident"
},
"invocationMethod": {
"type": "GITHUB",
"org": "<GITHUB_ORG>",
"repo": "<GITHUB_REPO>",
"workflow": "ecalate-an-incident.yaml",
"workflowInputs": {
"escalation_policy_id": "{{.inputs.\"escalation_policy_id\"}}",
"urgency": "{{.inputs.\"urgency\"}}",
"from": "{{.inputs.\"from\"}}",
"port_context": {
"blueprint": "{{.action.blueprint}}",
"entity": "{{.entity.identifier}}",
"run_id": "{{.run.id}}"
}
},
"reportWorkflowStatus": true
},
"requiredApproval": false,
"publish": true
}
Now you should see the Escalate Incidents
action in the self-service page. 🎉
Let's test it!
- Head to the Self Service hub
- Click on the
Escalate Incident
action - Choose the pagerduty incident you want to escalate (In case you didn't install the PagerDuty integration, it means you don't have any PagerDuty incidents in Port yet, so you will need to create one manually in Port to test this action)
- Select the new incident
- Enter the
Escalation Policy ID
,Urgency
andFrom
(email address of a valid pagerduty user associated with the account making the request). - Click on
Execute
- Done! wait for the incident's status to be changed in PagerDuty.
Congrats 🎉 You've escalated a PagerDuty incident in Port 🔥