Skip to main content

Datadog

在本示例中,您将在Datadog 和 Port 之间创建 webhook 集成,将警报和监控实体摄取到 Port,并将其映射到您的微服务实体。

Port 配置​

创建以下蓝图定义:

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
}
}
}

创建以下 webhook 配置using Port UI

Datadog webhook configuration
  1. 基本信息 选项卡 - 填写以下详细信息: 1.title: Datadog Alert Mapper; 2.标识符 : datadog_alert_mapper; 3.Description : 来自 Datadog 的警报/监控事件的 webhook 配置; 4.图标 : Datadog`;
  2. 集成配置选项卡 - 填写以下 JQ 映射:
    [
    {
    "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.单击页面底部的保存。

只有当 Port 微服务实体的标识符与 Datadog 中服务或主机的名称相匹配时,webhook 配置的关系映射才能正常运行。

在 Datadog 中创建 webhook​

  1. 使用您的凭据登录 Datadog;

  2. 点击页面左侧边栏的集成;

  3. 在搜索框中搜索Webhooks,然后选择它;

  4. 进入 "配置"选项卡,并按照安装说明进行操作;

  5. 点击新;

  6. 输入以下详细信息:

    1. 名称 Name - 被用于一个有意义的名称,如 Port_Webhook;
    2. URL - 输入creating the webhook configuration 后收到的 url 键的值;
    3. Payload - 当监控器触发警报时,此有效载荷将被发送到 webhook URL。您可以在文本框中输入此 JSON 占位符;
    {
    "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"
    }
    1. 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;

为了查看 Datadog webhook 中事件的不同有效载荷和结构、look here

完成!在 Datadog 实例上检测到的任何问题都将触发 webhook 事件。 Port 将根据映射解析事件,并相应地更新目录实体。

摄取服务级别目标(SLO)​

本指南将指导您完成将 Datadog SLO 导入 Port 的步骤。 按照这些步骤,您将能够在 Port 中创建一个 microservice 实体蓝图,代表 Datadog 帐户中的一个服务。 此外,您还将在此服务和 datadogSLO 蓝图之间建立关系,从而能够从 Datadog 帐户中导入所有已定义的 SLO。

Provider 提供的示例演示了如何使用 GitLab Pipelines 按预定时间间隔从 Datadog 的 REST API 提取数据并将数据报告给 Port。

从 APM 获取服务依赖性​

在本示例中,您将创建一个 service 蓝图,使用 REST API 在 Datadog APM 中引用所有服务及其相关依赖关系。 然后,您将添加一些 shell 脚本,以便每次 GitLab CI 被日程触发时在 Port 中创建新实体。

接收服务目录​

在本示例中,您将创建一个 datadogServiceCatalog 蓝图,用于从 Datadog 帐户中摄取所有服务目录。 然后,您将添加一些 python 脚本,以便向 Datadog REST API 进行 API 调用,并为您的帐户获取数据。