Create a PagerDuty Incident
Overview
This self service guide provides a comprehensive walkthrough on how to create an 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 service 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/create-an-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: Create PagerDuty Incident
on:
workflow_dispatch:
inputs:
title:
description: The title of the incident to create
required: true
type: string
extra_details:
description: Extra details about the incident to create
required: false
urgency:
description: The urgency of the incident
required: false
from:
description: The email address of a valid user associated with the account making the request.
required: true
port_context:
required: true
description: includes blueprint, run ID, and entity identifier from Port.
jobs:
trigger:
runs-on: ubuntu-latest
steps:
- uses: port-labs/pagerduty-incident-gha@v1
with:
portClientId: ${{ secrets.PORT_CLIENT_ID }}
portClientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
token: ${{ secrets.PAGERDUTY_API_KEY }}
portRunId: ${{fromJson(inputs.port_context).run_id}}
incidentTitle: "${{ inputs.title }}"
extraDetails: "${{ inputs.extra_details }}"
urgency: "${{ inputs.urgency }}"
actorEmail: "${{ inputs.from }}"
service: "${{fromJson(inputs.port_context).entity}}"
blueprintIdentifier: 'pagerdutyIncident'
Port Configuration
Create a new self service action using the following JSON configuration.
Create PagerDuty Incident (click to expand)
Make sure to replace <GITHUB_ORG>
and <GITHUB_REPO>
with your GitHub organization and repository names respectively.
{
"identifier": "pagerdutyService_create_incident",
"title": "Create Incident",
"icon": "pagerduty",
"description": "Notify users and teams about incidents in the service",
"trigger": {
"type": "self-service",
"operation": "DAY-2",
"userInputs": {
"properties": {
"title": {
"icon": "DefaultProperty",
"title": "Title",
"type": "string"
},
"extra_details": {
"title": "Extra Details",
"type": "string"
},
"urgency": {
"icon": "DefaultProperty",
"title": "Urgency",
"type": "string",
"default": "high",
"enum": [
"high",
"low"
],
"enumColors": {
"high": "yellow",
"low": "green"
}
},
"from": {
"title": "From",
"icon": "User",
"type": "string",
"format": "user",
"default": {
"jqQuery": ".user.email"
}
}
},
"required": [
"title",
"urgency",
"from"
],
"order": [
"title",
"urgency",
"from",
"extra_details"
]
},
"blueprintIdentifier": "pagerdutyService"
},
"invocationMethod": {
"type": "GITHUB",
"org": "<GITHUB_ORG>",
"repo": "<GITHUB_REPO>",
"workflow": "create-pagerduty-incident.yaml",
"workflowInputs": {
"title": "{{.inputs.\"title\"}}",
"extra_details": "{{.inputs.\"extra_details\"}}",
"urgency": "{{.inputs.\"urgency\"}}",
"from": "{{.inputs.\"from\"}}",
"port_context": {
"blueprint": "{{.action.blueprint}}",
"entity": "{{.entity.identifier}}",
"run_id": "{{.run.id}}",
"relations": "{{.entity.relations}}"
}
},
"reportWorkflowStatus": true
},
"requiredApproval": false,
"publish": true
}
Now you should see the Create Incident
action in the self-service page. 🎉
Let's test it!
- Head to the Self Service hub
- Click on the
Create Incident
action - Enter the required data for
Incident Title
,Service
, and optionally includeExtra Details
andUrgency
. - Click on
Execute
- Done! wait for the incident's status to be changed in PagerDuty
Congrats 🎉 You've created a PagerDuty incident in Port 🔥