Skip to main content

Dynatrace

在本示例中,您将在Dynatrace 和 Port 之间创建一个 webhook 集成,它将把问题实体摄取到 Port,并将其映射到您的微服务实体。

Port 配置

创建以下蓝图定义:

Dynatrace microservice blueprint
{
"identifier": "microservice",
"title": "Microservice",
"icon": "Service",
"schema": {
"properties": {
"description": {
"title": "Description",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
Dynatrace problem blueprint
{
"identifier": "dynatraceProblem",
"description": "This blueprint represents a Dynatrace problem in our software catalog",
"title": "Dynatrace Problem",
"icon": "Deployment",
"schema": {
"properties": {
"state": {
"type": "string",
"title": "Problem State"
},
"url": {
"type": "string",
"format": "url",
"title": "Problem URL"
},
"details": {
"type": "string",
"title": "Details"
},
"impact": {
"type": "string",
"title": "Problem Impact"
},
"severity": {
"type": "string",
"title": "Problem Severity"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"title": "Tags"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"microservice": {
"title": "Impacted Services",
"target": "microservice",
"required": false,
"many": true
}
}
}

创建以下 webhook 配置using Port's UI

Dynatrace problem webhook configuration
  1. 基本信息 选项卡 - 填写以下详细信息: 1.title: Dynatrace Problem Mapper; 2.标识符: dynatrace_problem_mapper; 3.Description : 来自 Dynatrace 的问题事件的 webhook 配置; 4.图标 : Dynatrace`;
  2. 集成配置选项卡 - 填写以下 JQ 映射:
    [
    {
    "blueprint": "dynatraceProblem",
    "entity": {
    "identifier": ".body.PID | tostring",
    "title": ".body.ProblemTitle",
    "properties": {
    "state": ".body.State",
    "url": ".body.ProblemURL",
    "details": ".body.ProblemDetailsText",
    "impact": ".body.ProblemImpact",
    "severity": ".body.ProblemSeverity",
    "tags": ".body.ProblemTags | split(\", \")"
    },
    "relations": {
    "microservice": "[.body.ImpactedEntities[].entity]"
    }
    }
    }
    ]

3.单击页面底部的保存

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

如果出现不匹配,可以利用Dynatrace Tags 对齐 Port 中的实际标识符。

为此,请创建一个关键字为 proj、值为 microservice_identifier 的标记。

然后,更新关系 JQ 语法,在 Dynatrace 问题和 Port 微服务之间建立连接。 以下是更新后的 JQ 映射:

{
"blueprint": "dynatraceProblem",
"entity": {
...Properties mappings
"relations": {
"microservice": ".body.ProblemTags | split(\", \") | map(select(test(\"proj:\")) | sub(\"proj:\";\"\"))"
}
}
}
Details

JQ expression explained The above JQ expression will split the tags by comma and space, then filter the tags that start with proj: and remove the proj: prefix from the tag value.

在 Dynatrace 中创建 webhook

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

  2. 单击页面左侧边栏的设置

  3. 选择集成,然后单击问题通知

  4. 选择添加通知

  5. 从可用的集成类型中选择自定义集成

  6. 输入以下详细信息:

    1. 显示名称"- 使用有意义的名称,如 Port Webhook;
    2. Webhook URL- 输入创建 Webhook 配置后收到的url` 键的值;
    3. Overview - 您可以在 webhook 请求中添加一个可选的 HTTP 标头;
    4. 自定义有效载荷"- 当在您的实体上检测或解决问题时,此有效载荷将被发送到 webhook URL。您可以在文本框中输入此 JSON 占位符;
    {
    "State":"{State}",
    "PID":"{PID}",
    "ProblemTitle":"{ProblemTitle}",
    "ImpactedEntity": "{ImpactedEntity}",
    "ProblemDetailsText": "{ProblemDetailsText}",
    "ProblemImpact": "{ProblemImpact}",
    "ProblemSeverity": "{ProblemSeverity}",
    "ProblemURL": "{ProblemURL}",
    "ProblemTags": "{Tags}",
    "ImpactedEntities": {ImpactedEntities}
    }
    1. Alerting profile - configure your preferred alerting rule or use the default one;
  7. Click Save changes at the bottom of the page;

要查看 Dynatrace webhooks 中可用的不同有效载荷和事件,请执行以下操作look here

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

Ingest Dynatrace Entities

在此示例中,您将创建一个 dynatrace_entity 蓝图,用于从 Dynatrace 帐户中摄取受监控的实体。 然后,您将添加一些 python 脚本,以调用 Dynatrace REST API 并获取帐户数据。