From 83b5e8230a038d46d8f46dc3c94543b14bf82809 Mon Sep 17 00:00:00 2001 From: kodjomiles Date: Sun, 17 Nov 2024 01:54:47 +0000 Subject: [PATCH] - modified trigger datadog incident to include an alternate incident trigger via ports sync webhook and secrets --- docs/guides/all/trigger-datadog-incident.md | 162 ++++++++++++++++++-- 1 file changed, 150 insertions(+), 12 deletions(-) diff --git a/docs/guides/all/trigger-datadog-incident.md b/docs/guides/all/trigger-datadog-incident.md index c56f59765..30b775af8 100644 --- a/docs/guides/all/trigger-datadog-incident.md +++ b/docs/guides/all/trigger-datadog-incident.md @@ -6,19 +6,13 @@ description: Learn how to trigger a Datadog incident in Port, ensuring effective # Trigger Datadog Incident This GitHub action allows you to quickly trigger incidents in Datadog directly from Port using Port's self service actions. +You can trigger incidents in Datadog using either the GitHub workflow method or the sync webhook method. ## Prerequisites -1. [Port's GitHub app](https://github.com/apps/getport-io) needs to be installed. -2. Datadog API Key. Head over to your account's [API and application keys page](https://app.datadoghq.com/account/settings) to create a new API key. The API key should have the `incident_write` permission scope. +1. [Port's GitHub app](https://github.com/apps/getport-io) needs to be installed if you are using the GitHub workflow method. +2. Datadog API Key. Head over to your account's [API and application keys page](https://app.datadoghq.com/account/settings) to create a new API key.
The API key should have the `incident_write` permission scope. 3. Datadog Application Key. This key is available on the same page as the Datadog API key. -4. In your GitHub repository, [go to **Settings > Secrets**](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) and add the following secrets: - * `DD_API_URL` - Datadog API URL by default should be [https://api.datadoghq.com](https://api.datadoghq.com). However, if you are on the Datadog EU site, set the secret to `https://api.datadoghq.eu`. If you have your region information you use `https://api..datadoghq.com` or `https://api..datadoghq.eu`. - * `DD_API_KEY` - Datadog API Key. - * `DD_APPLICATION_KEY` - Datadog Application Key. - * `PORT_CLIENT_ID` - Port Client ID [learn more](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/api/#get-api-token) - * `PORT_CLIENT_SECRET` - Port Client Secret [learn more](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/api/#get-api-token) - -5. Create a Datadog incident blueprint in Port using the schema below: +4. Create a Datadog incident blueprint in Port using the schema below:
Datadog Incident Blueprint @@ -109,7 +103,19 @@ This GitHub action allows you to quickly trigger incidents in Datadog directly f
-## GitHub Workflow +## Trigger via GitHub workflow +This method uses a GitHub workflow to trigger Datadog incidents. +The workflow is triggered by a self-service action in Port, which sends the required data to the GitHub workflow. + +### Add GitHub secrets +In your GitHub repository, [go to **Settings > Secrets**](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) and add the following secrets: + * `DD_API_URL` - Datadog API URL by default should be [https://api.datadoghq.com](https://api.datadoghq.com).
However, if you are on the Datadog EU site, set the secret to `https://api.datadoghq.eu`.
If you have your region information you use `https://api..datadoghq.com` or `https://api..datadoghq.eu`. + * `DD_API_KEY` - Datadog API Key. + * `DD_APPLICATION_KEY` - Datadog Application Key. + * `PORT_CLIENT_ID` - Port Client ID [learn more](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/api/#get-api-token) + * `PORT_CLIENT_SECRET` - Port Client Secret [learn more](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/api/#get-api-token) + +### Workflow Create the file `trigger-datadog-incident.yml` in the `.github/workflows` folder of your repository and copy the content of the workflow configuration below: :::tip Dedicated repository @@ -247,7 +253,7 @@ jobs: -## Port Configuration +### Port configuration On the [self-service](https://app.getport.io/self-serve) page, create the Port action against the `Datadog Incident` blueprint. This will trigger the GitHub workflow.
@@ -341,6 +347,138 @@ Make sure to replace `` and `` with your GitHub organiz ```
+ +## Alternative trigger via webhook + +In addition to triggering Datadog incidents via GitHub Actions, +you can leverage on Port's **synced webhooks** and **secrets** to directly interact with Datadog's API. +This method simplifies the setup by handling everything within Port. + + + +### Add Port secrets +Add the following secrets to your Port account: + +1. Click on the `...` button next to the profile icon in the top right conner. +2. Click on **Credentials**. +3. Click on the `Secrets` tab. +4. Click on `+ Secret` and add the following secrets: + - `DD_API_KEY`: Your Datadog API Key. + - `DD_APPLICATION_KEY`: Your Datadog Application Key. + +### Port configuration +Create a new self service action that uses a synced webhook to trigger a Datadog incident using the following JSON configuration. + +
+Trigger Datadog Incident Action Using Synced Webhook (Click to expand) + +:::tip Modification Required +Make sure to replace `` with your Datadog API URL. +Datadog API URL by default should be [https://api.datadoghq.com](https://api.datadoghq.com). +However, if you are on the Datadog EU site, set the secret to `https://api.datadoghq.eu`. +If you have your region information you use `https://api..datadoghq.com` or `https://api..datadoghq.eu`. +::: + +```json showLineNumbers +{ + "identifier": "datadogIncident_trigger_datadog_incident_webhook", + "title": "Trigger Datadog Incident (Webhook)", + "icon": "Datadog", + "description": "Triggers a Datadog incident using a synced webhook", + "trigger": { + "type": "self-service", + "operation": "CREATE", + "userInputs": { + "properties": { + "title": { + "title": "Title", + "description": "The title of the incident, summarizing what happened.", + "type": "string" + }, + "customerImpacted": { + "title": "Customer Impacted", + "description": "Indicates whether the incident caused customer impact.", + "type": "boolean", + "default": false + }, + "customerImpactScope": { + "icon": "DefaultProperty", + "title": "Customer Impact Scope", + "description": "Summary of the impact experienced by customers.", + "type": "string" + }, + "notificationHandleName": { + "title": "Notification Handle Name", + "description": "The name of the notification handle.", + "type": "string" + }, + "notificationHandleEmail": { + "title": "Notification Handle Email", + "description": "The email address used for the notification.", + "type": "string", + "pattern": "^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$" + } + }, + "required": [ + "title", + "customerImpacted", + "notificationHandleName", + "notificationHandleEmail", + "customerImpactScope" + ], + "order": [ + "title", + "customerImpacted", + "customerImpactScope", + "notificationHandleName", + "notificationHandleEmail" + ] + }, + "blueprintIdentifier": "datadogIncident" + }, + "invocationMethod": { + "type": "WEBHOOK", + "url": "/api/v2/incidents", + "agent": false, + "synchronized": true, + "method": "POST", + "headers": { + "Content-Type": "application/json", + "DD-API-KEY": "{{ .secrets.DD_API_KEY }}", + "DD-APPLICATION-KEY": "{{ .secrets.DD_APPLICATION_KEY }}" + }, + "body": { + "data": { + "type": "incidents", + "attributes": { + "customer_impact_scope": "{{.inputs.\"customerImpactScope\"}}", + "customer_impacted": "{{.inputs.\"customerImpacted\"}}", + "title": "{{.inputs.\"title\"}}", + "notification_handles": [ + { + "display_name": "{{.inputs.\"notificationHandleName\"}}", + "handle": "{{.inputs.\"notificationHandleEmail\"}}" + } + ] + } + } + } + }, + "requiredApproval": false, + "publish": true +} +``` + +
+ +:::note Install the Datadog Integration +Triggering the incident data via the api will not automatically update the incident data in your Port catalog. +To ensure that the Datadog incident data remains up to date in your catalog, [install the Datadog integration](/build-your-software-catalog/sync-data-to-catalog/apm-alerting/datadog/) in Port. +This integration will automatically synchronize incident updates from Datadog to your Port catalog. +::: + + + ## Let's test it 1. Trigger the action from Port's [Self Serve hub](https://app.getport.io/self-serve)