Skip to main content

新 Relic

通过我们的 New Relic 集成,您可以根据您的映射和定义,将 New Relic 云账户中的 "实体 "和 "问题 "导入 Port。

实体 "可以是主机、应用程序、服务、数据库或任何其他向 New Relic 发送数据的组件。 问题 "是一组描述症状的相应问题的事件。

常见被用于情况

  • 将 New Relic 中受监控的应用程序和服务与其当前打开的警报进行映射。
  • 关注受监控应用程序上发出的新警报和更新,并自动将它们同步到 Port 中。

先决条件

To install the integration, you need a Kubernetes cluster that the integration's container chart will be deployed to.

Please make sure that you have kubectl and helm installed on your machine, and that your kubectl CLI is connected to the Kubernetes cluster where you plan to install the integration.

安装

从以下安装方法中选择一种:

被用于此安装选项意味着集成将能实时更新 Port。

本表总结了安装时可用的参数,请在下面的脚本中按自己的需要进行设置,然后复制并在终端运行:

ParameterDescriptionRequired
port.clientIdYour port client id
port.clientSecretYour port client secret
port.baseUrlYour port base url, relevant only if not using the default port app
integration.identifierChange the identifier to describe your integration
integration.typeThe integration type
integration.eventListener.typeThe event listener type
integration.secrets.newRelicAPIKeyThe New Relic API key
integration.secrets.newRelicAccountIDThe New Relic account ID
scheduledResyncIntervalThe number of minutes between each resync
initializePortResourcesDefault true, When set to true the integration will create default blueprints and the port App config Mapping

To install the integration using Helm, run the following command:

如果您正在引用 New Relic 的欧盟地区,请在命令中添加以下 flag:

-set integration.config.newRelicGraphqlURL="https://api.eu.newrelic.com/graphql"

# The following script will install an Ocean integration at your K8s cluster using helm
# initializePortResources: When set to true the integration will create default blueprints + JQ Mappings
# scheduledResyncInterval: the number of minutes between each resync
# integration.identifier: Change the identifier to describe your integration

helm repo add --force-update port-labs https://port-labs.github.io/helm-charts
helm upgrade --install my-newrelic-integration port-labs/port-ocean \
--set port.clientId="PORT_CLIENT_ID" \
--set port.clientSecret="PORT_CLIENT_SECRET" \
--set port.baseUrl="https://api.getport.io" \
--set initializePortResources=true \
--set scheduledResyncInterval=120 \
--set integration.identifier="my-newrelic-integration" \
--set integration.type="newrelic" \
--set integration.eventListener.type="POLLING" \
--set integration.secrets.newRelicAPIKey="<NR_API_KEY>" \
--set integration.secrets.newRelicAccountID="<NR_ACCOUNT_ID>"

事件监听器

该集成使用轮询方式,每分钟从 Port 中提取一次配置,并检查配置是否有变化。 如果有变化,就会重新同步。

高级集成配置

有关代理或自签名证书等高级配置,click here

Ingesting Newrelic objects

Newrelic 集成使用 YAML 配置来描述将数据加载到开发者门户的过程。

下面是配置中的一个示例片段,演示了从 Newrelic 获取 "问题 "数据的过程:

resources:
- kind: newRelicAlert
selector:
query: "true"
newRelicTypes: ["ISSUE"]
port:
entity:
mappings:
blueprint: '"newRelicAlert"'
identifier: .issueId
title: .title[0]
properties:
priority: .priority
state: .state
sources: .sources
conditionName: .conditionName
alertPolicyNames: .policyName
activatedAt: .activatedAt
relations:
newRelicService: .__APPLICATION.entity_guids + .__SERVICE.entity_guids

该集成利用JQ JSON processor 对来自 Newrelic API 事件的现有字段和 Values 进行选择、修改、连接、转换和其他操作。

配置结构

集成配置决定了从 Newrelic 查询哪些资源,以及在 Port 中创建哪些实体和属性。

支持的资源 以下资源可被用于来映射来自 Newrelic 的数据,可以引用下面链接的 API 响应中出现的任何字段来进行映射配置。
  • 集成配置的根密钥是 "资源 "密钥:

    resources:
    - kind: project
    selector:
    ...
  • 类型 "键是 Newrelic 对象的指定符:

      resources:
    - kind: project
    selector:
    ...
  • 通过 "选择器 "键,可以筛选出哪些指定 "类型 "的对象将被收录到软件目录中:

    resources:
    - kind: newRelicService
    selector:
    query: "true"
    newRelicTypes: ["SERVICE", "APPLICATION"]
    calculateOpenIssueCount: true
    entityQueryFilter: "type in ('SERVICE','APPLICATION')"
    entityExtraPropertiesQuery: |
    ... on ApmApplicationEntityOutline {
    guid
    name
    }
  • newRelicTypes - 将被获取的 Newrelic 实体类型数组。默认值为['服务'、'应用程序']。这与 Newrelic 实体中的类型字段有关。

  • calculateOpenIssueCount:

    • 布尔值,表示集成是否应计算每个实体的开放问题数量。默认值为 "false"。
    • 注意 - 这可能会导致性能降级,因为集成必须计算每个实体的开放问题数,但不幸的是,New Relic API 并不支持这一点。
  • 实体查询过滤器: ** **

    • 将应用于 New Relic API 查询的过滤器。它将放在 New Relic GraphQL API 中entitySearch查询的query字段内。查询过滤器示例click here
    • 不指定此字段将导致集成获取所有实体并将它们映射到kind中定义的蓝图。
    • 经验法则--大多数情况下,"EntityQueryFilter "与 "NewRelicTypes "相同。例如,如果我们想获取所有服务和应用程序,我们将把 EntityQueryFilter 设置为 type in ('SERVICE','APPLICATION') ,把 NewRelicTypes 设置为 ['SERVICE','APPLICATION']
  • **实体额外属性查询: **

    • 这是一个可选属性,允许为每个 Newrelic 实体定义要获取的额外属性。这将与我们在 Newrelic GraphQL API 中的 "实体搜索 "查询中的 "实体 "部分下请求的默认查询属性连接起来。有关其他查询属性的示例,请访问click here
  • Port"、"实体 "和 "映射 "键被用来将 Newrelic 对象字段映射到Port实体。要创建多个同类映射,可在 resources 数组中添加另一项;

    resources:
    - kind: newRelicAlert
    selector:
    query: "true"
    newRelicTypes: ["ISSUE"]
    port:
    entity:
    mappings:
    blueprint: '"newRelicAlert"'
    identifier: .issueId
    title: .title[0]
    properties:
    priority: .priority
    state: .state
    sources: .sources
    conditionName: .conditionName
    alertPolicyNames: .policyName
    activatedAt: .activatedAt
    relations:
    newRelicService: .__APPLICATION.entity_guids + .__SERVICE.entity_guids
    - kind: newRelicAlert # In this instance project is mapped again with a different filter
    selector:
    query: '.name == "MyIssuetName"'
    port:
    entity:
    mappings: ...
蓝图键 注意 blueprint 键的值 - 如果要使用硬编码字符串,需要用 2 组引号封装,例如使用一对单引号 ('),然后再用一对双引号 ("): :::

标签

一些 Newrelic "实体 "有一个名为 "标签 "的属性,其中包含机器信息、主机名、代理名称和版本等可能有用的信息。 例如:

"tags": [
{
"key": "coreCount",
"values": [
"10"
]
},
{
"key": "hostStatus",
"values": [
"running"
]
},
]

在映射之前,该集成会对每个 "标签 "进行转换,转换之后,上面的示例就会变成这样:

tags = ["coreCount":"10","hostStatus":"running"]

将数据输入Port

要使用integration configuration 引用 Newrelic 对象,可以按照以下步骤操作:

  1. 转到 DevPortal Builder 页面。
  2. 选择要被 Newrelic 引用的蓝图。
  3. 从菜单中选择采集数据选项。
  4. 在 APM 和警报类别下选择 Newrelic。
  5. integration configuration 的内容添加到编辑器中。
  6. 单击 "Resync"。

示例

蓝图和相关集成配置示例:

服务(实体)

Service blueprint
{
"identifier": "newRelicService",
"description": "This blueprint represents a New Relic service or application in our software catalog",
"title": "New Relic Service",
"icon": "NewRelic",
"schema": {
"properties": {
"has_apm": {
"title": "Has APM",
"type": "boolean"
},
"open_issues_count": {
"title": "Open Issues Count",
"type": "number",
"default": 0
},
"link": {
"title": "Link",
"type": "string",
"format": "url"
},
"reporting": {
"title": "Reporting",
"type": "boolean"
},
"tags": {
"title": "Tags",
"type": "object"
},
"account_id": {
"title": "Account ID",
"type": "string"
},
"type": {
"title": "Type",
"type": "string"
},
"domain": {
"title": "Domain",
"type": "string"
},
"throughput": {
"title": "Throughput",
"type": "number"
},
"response_time_avg": {
"title": "Response Time AVG",
"type": "number"
},
"error_rate": {
"title": "Error Rate",
"type": "number"
},
"instance_count": {
"title": "Instance Count",
"type": "number"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
Integration configuration
- kind: newRelicService
selector:
query: "true"
newRelicTypes: ["SERVICE", "APPLICATION"]
calculateOpenIssueCount: true
entityQueryFilter: "type in ('SERVICE','APPLICATION')"
entityExtraPropertiesQuery: |
... on ApmApplicationEntityOutline {
guid
name
alertSeverity
applicationId
apmBrowserSummary {
ajaxRequestThroughput
ajaxResponseTimeAverage
jsErrorRate
pageLoadThroughput
pageLoadTimeAverage
}
apmSummary {
apdexScore
errorRate
hostCount
instanceCount
nonWebResponseTimeAverage
nonWebThroughput
responseTimeAverage
throughput
webResponseTimeAverage
webThroughput
}
}
port:
entity:
mappings:
blueprint: '"newRelicService"'
identifier: .guid
title: .name
properties:
has_apm: 'if .domain | contains("APM") then "true" else "false" end'
link: .permalink
open_issues_count: .__open_issues_count
reporting: .reporting
tags: .tags
domain: .domain
type: .type

问题

Issue blueprint
{
"identifier": "newRelicAlert",
"description": "This blueprint represents a New Relic alert in our software catalog",
"title": "New Relic Alert",
"icon": "NewRelic",
"schema": {
"properties": {
"priority": {
"type": "string",
"title": "Priority",
"enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW"],
"enumColors": {
"CRITICAL": "red",
"HIGH": "red",
"MEDIUM": "yellow",
"LOW": "green"
}
},
"state": {
"type": "string",
"title": "State",
"enum": ["ACTIVATED", "CLOSED", "CREATED"],
"enumColors": {
"ACTIVATED": "yellow",
"CLOSED": "green",
"CREATED": "lightGray"
}
},
"trigger": {
"type": "string",
"title": "Trigger"
},
"sources": {
"type": "array",
"title": "Sources"
},
"alertPolicyNames": {
"type": "array",
"title": "Alert Policy Names"
},
"conditionName": {
"type": "array",
"title": "Condition Name"
},
"activatedAt": {
"type": "string",
"title": "Time Issue was activated"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"newRelicService": {
"title": "New Relic Service",
"target": "newRelicService",
"required": false,
"many": true
}
}
}
Integration configuration
- kind: newRelicAlert
selector:
query: "true"
newRelicTypes: ["ISSUE"]
port:
entity:
mappings:
blueprint: '"newRelicAlert"'
identifier: .issueId
title: .title[0]
properties:
priority: .priority
state: .state
sources: .sources
conditionName: .conditionName
alertPolicyNames: .policyName
activatedAt: .activatedAt
relations:
newRelicService: .__APPLICATION.entity_guids + .__SERVICE.entity_guids