{"id":20038662,"url":"https://github.com/defra/cdp-notify","last_synced_at":"2026-05-15T05:02:44.902Z","repository":{"id":261401624,"uuid":"874839600","full_name":"DEFRA/cdp-notify","owner":"DEFRA","description":"Git repository for service cdp-notify","archived":false,"fork":false,"pushed_at":"2026-04-24T13:09:48.000Z","size":325,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-04-24T15:16:46.474Z","etag":null,"topics":["backend","cdp","node","service"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DEFRA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-18T14:55:34.000Z","updated_at":"2026-04-24T13:07:49.000Z","dependencies_parsed_at":"2024-11-06T11:42:17.333Z","dependency_job_id":"836da25d-6331-4fa7-8a04-ec2dc98c09a6","html_url":"https://github.com/DEFRA/cdp-notify","commit_stats":null,"previous_names":["defra/cdp-notify"],"tags_count":45,"template":false,"template_full_name":null,"purl":"pkg:github/DEFRA/cdp-notify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fcdp-notify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fcdp-notify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fcdp-notify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fcdp-notify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DEFRA","download_url":"https://codeload.github.com/DEFRA/cdp-notify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fcdp-notify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33054454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-15T02:00:06.351Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","cdp","node","service"],"created_at":"2024-11-13T10:31:44.934Z","updated_at":"2026-05-15T05:02:44.896Z","avatar_url":"https://github.com/DEFRA.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cdp-notify\n\nHow the pager duty integration works.\n\n`cdp-notify` receives grafana alerts, the same as the email notification service.\n\nExample grafana alert message:\n\n```\n{\n  environment: 'prod',\n  service: 'test-service',\n  team: 'Platform',\n  alertName: 'test-service - prod',\n  status: 'firing',\n  startsAt: '2024-11-04 12:53:20 +0000 UTC',\n  endsAt: '2024-11-04 12:53:20 +0000 UTC',\n  summary: 'A test suite',\n  description: '',\n  series: '',\n  runbookUrl: '',\n  alertURL: 'https://grafana/alerting/grafana/0000/view'\n}\n```\n\nWhen processing an event the pager duty handler does the following:\n\n1. If the alert does not contain the field `pagerDuty=\"true\"` (note: `\"true\"` is a quoted string, NOT a boolean) then no alert is sent\n\n2. Decides if the alert comes from an environment we want to handle.\n   This is done by comparing the `environment` field in the alert to either: alertEnvironments from config (default: `[prod]`) or to the environment field in `~/src/config/pagerduty-service-overides.js` if an entry exist for that service.\n   If there is no match then the alert is not processed\n\n3. Find all pager-duty integration keys for the alert\n   This is done in several steps:\n\n   - First, find the team that owns the service.\n   - If there is an entry for the service in `~/src/config/pagerduty-service-overides.js` use the teams set there.\n   - If not, look up the teams for the service from cdp-portal-backend.\n   - For each team see if there is a config entry matching `pagerduty.teams.${team}.integrationKey`\n   - If no matches are found check the config for `pagerduty.services.${service}.integrationKey`\n   - If no matches are found the alert is not processed.\n\n4. Check if sending alerts is enabled\n   If `pagerduty.sendAlerts` is set to false in config no alerts will be sent.\n5. Check if alert has a status of either `firing` or `resolve`.\n   The status is remapped from `firing` to `trigger` and `resolved` to `resolve`.\n6. Generate a deduplication key\n   This is a md5 hash of the service, environment and alertURL field.\n7. Call the pager duty api\n   A payload is built using the integration key, alert details, status and deduplication key.\n\n## PagerDuty Config\n\n### Adding a new tenant service to pager-duty\n\nFind the team name as it appears in portal for the owner of the service.\nEnsure the team is setup in pager-duty and an integration key is generated.\nIn cdp-notify add a new entry to ~/src/config/index.js to `pagerduty.teams`\n\n```\n pagerduty: {\n  teams: {\n    'my-new-team': {\n      integrationKey: {\n      doc: 'Integration key for digital service',\n      format : String,\n      default: 'key',\n      env : 'MY_NEW_TEAM_INTEGRATION_KEY'\n    }\n  }\n}\n```\n\nIn add the team's pagerduty integration key as a secret to cdp-notify with an ID matching the id set in the new config entry (e.g. MY_NEW_TEAM_INTEGRATION_KEY).\nRedeploy the service.\n\n### Sending alerts for non-tenant services\n\nTo send pager duty alerts for non-tenant services (e.g. mongodb, lambdas, workflows etc) add a new entry to `service-override.js`.\n\n```\n{\n 'my-non-tenant-service': {\n    teams: ['Team-to-Alert']\n  }\n}\n```\n\nOptionally you can specify an array of environment names if you want cdp-notify to alert from non-prod environments.\nThe name entry in the overrides file must match the service field of the grafana alert. The team must also be configured in cdp-notify (see above).\n\n## Local Dev\n\nDependencies:\n\n- cdp-portal-stubs\n- cdp-user-service-backend\n- cdp-portal-backend\n- localstack\n\nQueue setup:\n\n```\n$ awslocal sqs create-queue --queue-name cdp_grafana_alerts\n```\n\nDatabase Setup\n\n```\nuse cdp-portal-backend\ndb.teams.update({}, {$set: {alertEmailAddresses: [\"test@email\"]}})\n```\n\n(this adds test@email to all teams)\n\nTesting locally\n\n```\npayload='{\"environment\":\"prod\",\"team\":\"Platform\",\"service\":\"cdp-notify\",\"alertName\":\"cdp-notify-ops - Average Response Time\",\"status\":\"resolved\",\"startsAt\":\"2024-11-04 16:42:10 +0000 UTC\",\"endsAt\":\"2024-11-04 16:47:10 +0000 UTC\",\"summary\":\"Average Response Time Alert in milliseconds of the responseTime value in Opensearch.\",\"description\":\"Average Response Time Alert\",\"series\":\"\",\"runbookUrl\":\"\",\"alertURL\":\"https://metrics/alerting/grafana/0/view\"}\nawslocal sqs send-message --queue-url http://sqs.eu-west-2.127.0.0.1:4566/000000000000/cdp_grafana_alerts --message-body \"$payload\"\n```\n\n## Licence\n\nTHIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:\n\n\u003chttp://www.nationalarchives.gov.uk/doc/open-government-licence/version/3\u003e\n\nThe following attribution statement MUST be cited in your products and applications when using this information.\n\n\u003e Contains public sector information licensed under the Open Government license v3\n\n### About the licence\n\nThe Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable\ninformation providers in the public sector to license the use and re-use of their information under a common open\nlicence.\n\nIt is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fcdp-notify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefra%2Fcdp-notify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fcdp-notify/lists"}