Skip to main content

Datadog

In this example you are going to create a webhook integration between Datadog and Port, which will ingest alerts and monitors entities to Port and map them to your microservice entities.

Port configuration​

Create the following blueprint definitions:

Datadog microservice blueprint
{
"identifier": "microservice",
"title": "Microservice",
"icon": "Service",
"schema": {
"properties": {
"description": {
"title": "Description",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
Datadog alert/monitor blueprint
{
"identifier": "datadogAlert",
"description": "This blueprint represents a Datadog monitor/alert in our software catalog",
"title": "Datadog Alert",
"icon": "Datadog",
"schema": {
"properties": {
"url": {
"type": "string",
"format": "url",
"title": "Event URL"
},
"message": {
"type": "string",
"title": "Details"
},
"eventType": {
"type": "string",
"title": "Event Type"
},
"priority": {
"type": "string",
"title": "Metric Priority"
},
"creator": {
"type": "string",
"title": "Creator"
},
"alertMetric": {
"type": "string",
"title": "Alert Metric"
},
"alertType": {
"type": "string",
"title": "Alert Type",
"enum": ["error", "warning", "success", "info"]
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"title": "Tags"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"microservice": {
"title": "Services",
"target": "microservice",
"required": false,
"many": false
}
}
}

Create the following webhook configuration using Port UI

Datadog webhook configuration
  1. Basic details tab - fill the following details:

    1. Title : Datadog Alert Mapper;
    2. Identifier : datadog_alert_mapper;
    3. Description : A webhook configuration for alerts/monitors events from Datadog;
    4. Icon : Datadog;
  2. Integration configuration tab - fill the following JQ mapping:

    [
    {
    "blueprint": "datadogAlert",
    "entity": {
    "identifier": ".body.alert_id | tostring",
    "title": ".body.title",
    "properties": {
    "url": ".body.event_url",
    "message": ".body.message",
    "eventType": ".body.event_type",
    "priority": ".body.priority",
    "creator": ".body.creator",
    "alertMetric": ".body.alert_metric",
    "alertType": ".body.alert_type",
    "tags": ".body.tags | split(\", \")"
    },
    "relations": {
    "microservice": ".body.service"
    }
    }
    }
    ]
  3. Click Save at the bottom of the page.

note

The webhook configuration's relation mapping will function properly only when the identifiers of the Port microservice entities match the names of the services or hosts in your Datadog.

Create a webhook in Datadog​

  1. Log in to Datadog with your credentials;
  2. Click on Integrations at the left sidebar of the page;
  3. Search for Webhooks in the search box and select it;
  4. Go to the Configuration tab and follow the installation instructions;
  5. Click on New;
  6. Input the following details:
    1. Name - use a meaningful name such as Port_Webhook;
    2. URL - enter the value of the url key you received after creating the webhook configuration;
    3. Payload - When an alert is triggered on your monitors, this payload will be sent to the webhook URL. You can enter this JSON placeholder in the textbox;
      {
      "id": "$ID",
      "message": "$TEXT_ONLY_MSG",
      "priority": "$PRIORITY",
      "last_updated": "$LAST_UPDATED",
      "event_type": "$EVENT_TYPE",
      "event_url": "$LINK",
      "service": "$HOSTNAME",
      "creator": "$USER",
      "title": "$EVENT_TITLE",
      "date": "$DATE",
      "org_id": "$ORG_ID",
      "org_name": "$ORG_NAME",
      "alert_id": "$ALERT_ID",
      "alert_metric": "$ALERT_METRIC",
      "alert_status": "$ALERT_STATUS",
      "alert_title": "$ALERT_TITLE",
      "alert_type": "$ALERT_TYPE",
      "tags": "$TAGS"
      }
    4. Custom Headers - configure any custom HTTP header to be added to the webhook event. The format for the header should be in JSON;
  7. Click Save at the bottom of the page;
tip

In order to view the different payloads and structure of the events in Datadog webhooks, look here

Done! any problem detected on your Datadog instance will trigger a webhook event. Port will parse the events according to the mapping and update the catalog entities accordingly.

Ingest service level objectives (SLOs)​

This guide will walk you through the steps to ingest Datadog SLOs into Port. By following these steps, you will be able to create a blueprint for a microservice entity in Port, representing a service in your Datadog account. Furthermore, you will establish a relation between this service and the datadogSLO blueprint, allowing the ingestion of all defined SLOs from your Datadog account.

The provided example demonstrates how to pull data from Datadog's REST API at scheduled intervals using GitLab Pipelines and report the data to Port.

Ingest service dependency from your APM​

In this example, you will create a service blueprint that ingests all services and their related dependencies in your Datadog APM using REST API. You will then add some shell script to create new entities in Port every time GitLab CI is triggered by a schedule.

Ingest service catalog​

In this example, you will create a datadogServiceCatalog blueprint that ingests all service catalogs from your Datadog account. You will then add some python script to make API calls to Datadog REST API and fetch data for your account.