Skip to content

Commit f01d4ae

Browse files
authored
Merge pull request #396 from flashcatcloud/codex/new-relic-alert-integration-main
docs(integration): add New Relic alert setup
2 parents 170b733 + 9f3327e commit f01d4ae

4 files changed

Lines changed: 269 additions & 0 deletions

File tree

‎docs.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,7 @@
16801680
"zh/on-call/integration/alert-integration/alert-sources/prometheus",
16811681
"zh/on-call/integration/alert-integration/alert-sources/grafana",
16821682
"zh/on-call/integration/alert-integration/alert-sources/datadog",
1683+
"zh/on-call/integration/alert-integration/alert-sources/new-relic",
16831684
"zh/on-call/integration/alert-integration/alert-sources/zabbix",
16841685
"zh/on-call/integration/alert-integration/alert-sources/flashcat",
16851686
"zh/on-call/integration/alert-integration/alert-sources/open-falcon",
@@ -3048,6 +3049,7 @@
30483049
"en/on-call/integration/alert-integration/alert-sources/prometheus",
30493050
"en/on-call/integration/alert-integration/alert-sources/grafana",
30503051
"en/on-call/integration/alert-integration/alert-sources/datadog",
3052+
"en/on-call/integration/alert-integration/alert-sources/new-relic",
30513053
"en/on-call/integration/alert-integration/alert-sources/zabbix",
30523054
"en/on-call/integration/alert-integration/alert-sources/flashcat",
30533055
"en/on-call/integration/alert-integration/alert-sources/open-falcon",
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: "New Relic alert integration"
3+
description: "Send New Relic Issues to Flashduty On-call through Workflow webhooks and correlate activation, update, and closure notifications."
4+
keywords: ["alert integration", "New Relic", "Workflow", "webhook", "Issue"]
5+
---
6+
7+
Use a New Relic Workflow webhook to send Issues to Flashduty On-call. One New Relic Issue maps to one Flashduty alert. Priority changes, Alert Event additions or closures, Issue merges, and closure notifications update that alert.
8+
9+
<div className="hide">
10+
11+
## In Flashduty On-call
12+
---
13+
14+
Create either a dedicated or shared **New Relic** alert integration and copy its complete Push URL.
15+
16+
</div>
17+
18+
## Configure New Relic
19+
---
20+
21+
<Steps>
22+
<Step title="Create a webhook destination">
23+
24+
1. In New Relic, go to **Alerts → Enrich and Notify → Destinations**
25+
2. Create a **Webhook** destination named `Flashduty`
26+
3. Paste the complete Flashduty integration Push URL into Endpoint URL
27+
28+
</Step>
29+
30+
<Step title="Create a workflow">
31+
32+
Create a Workflow whose Issue filters select the required policies, conditions, entities, or tags. Add the webhook destination. Enable at least **Activated** and **Closed**. Also enable **Priority changed** and **Other updates** to receive priority changes, Alert Event membership changes, and post-merge snapshots.
33+
34+
</Step>
35+
36+
<Step title="Configure the payload">
37+
38+
```json
39+
{
40+
"issue_id": "{{issueId}}",
41+
"issue_url": {{json issuePageUrl}},
42+
"title": {{json issueTitle}},
43+
"description": {{json accumulations.conditionDescription.[0]}},
44+
"priority": "{{priority}}",
45+
"state": "{{state}}",
46+
"trigger_event": "{{triggerEvent}}",
47+
"is_correlated": {{isCorrelated}},
48+
"account_id": {{nrAccountId}},
49+
"incident_ids": {{json incidentIds}},
50+
"sources": {{json accumulations.sources}},
51+
"policy_names": {{json accumulations.policyName}},
52+
"condition_names": {{json accumulations.conditionName}},
53+
"entity_names": {{json entitiesData.names}},
54+
"entity_ids": {{json entitiesData.ids}},
55+
"workflow_name": {{json workflowName}}
56+
}
57+
```
58+
59+
Keep `issue_id`, `state`, and `priority`. Flashduty rejects a missing `issue_id` because a random key cannot correlate later updates and closure.
60+
61+
</Step>
62+
63+
<Step title="Verify the lifecycle">
64+
65+
Open a real Issue and confirm an active Flashduty alert. Change its priority or add another Alert Event and confirm an update on the same alert. Finally close the Issue and confirm the original alert recovers. A test notification proves connectivity only, not lifecycle correlation.
66+
67+
</Step>
68+
</Steps>
69+
70+
## Alert Key and Issue merges
71+
---
72+
73+
Flashduty uses `issue_id` (`issueId`) directly as the Alert Key. Titles, priorities, policies, conditions, entities, and `incident_ids` do not affect it. `incident_ids` is the list of Alert Events aggregated into the Issue and is stored only as context.
74+
75+
For `trigger_event=MERGE_REQUEST`, Flashduty updates the surviving Issue identified by the payload's `issue_id`. This version does not invoke Flashduty's internal alert merge operation or infer and close a source Issue.
76+
77+
## Status and severity
78+
---
79+
80+
| New Relic value | Flashduty status or severity |
81+
| :--- | :--- |
82+
| `state = CLOSED` | Recovered |
83+
| `state = CREATED` or `ACTIVATED` | Active alert |
84+
| `priority = CRITICAL` | Critical |
85+
| `priority = HIGH` | Warning |
86+
| `priority = MEDIUM` or `LOW` | Info |
87+
| Empty or unknown priority | Warning |
88+
89+
New Relic warning thresholds create `HIGH` priority Alert Events, so `HIGH` maps to Flashduty Warning. Use an [Alert Processing Pipeline](/en/on-call/integration/alert-integration/alert-pipelines) for a different mapping.
90+
91+
## Add custom labels
92+
---
93+
94+
Add a top-level `custom_labels` object to send more Workflow variables:
95+
96+
```json
97+
{
98+
"issue_id": "{{issueId}}",
99+
"priority": "{{priority}}",
100+
"state": "{{state}}",
101+
"custom_labels": {
102+
"team": {{json accumulations.tag.team.[0]}},
103+
"environment": {{json accumulations.tag.environment.[0]}},
104+
"muting_state": "{{mutingState}}",
105+
"open_alert_events": {{openIncidentsCount}}
106+
}
107+
}
108+
```
109+
110+
`custom_labels` accepts at most 50 entries. Use snake_case keys. Strings, numbers, booleans, arrays, and objects are accepted; arrays and objects are stored as JSON strings. Empty values are discarded, built-in labels win collisions, and the final event may contain at most 50 labels. Never send secrets.
111+
112+
For the complete variable list, see [New Relic Workflow variables](https://docs.newrelic.com/docs/alerts/get-notified/custom-variables-alert-event-workflows/).

‎integration-docs/src/doc-map.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const docMap = {
6464
JDCloudMonitor: `${alertBase}/jdcloud.mdx`,
6565
KSCloudMonitor: `${alertBase}/kscloud-monitor.mdx`,
6666
Datadog: `${alertBase}/datadog.mdx`,
67+
NewRelic: `${alertBase}/new-relic.mdx`,
6768
AliyunPrometheus: `${alertBase}/aliyun-prometheus.mdx`,
6869
HttpPull: `${alertBase}/http-pull.mdx`,
6970
DbPull: `${alertBase}/db-pull.mdx`,
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
title: "New Relic 告警集成"
3+
description: "通过 Workflow Webhook 将 New Relic Issue 同步到 Flashduty On-call,并关联激活、更新和关闭事件。"
4+
keywords: ["告警集成", "New Relic", "Workflow", "Webhook", "Issue"]
5+
---
6+
7+
通过 New Relic Workflow Webhook 将 Issue 同步到 Flashduty On-call。一个 New Relic Issue 对应一条 Flashduty 告警;同一 Issue 后续发生等级变化、Alert Event 加入或关闭、Issue 合并、关闭时,会继续更新这条告警。
8+
9+
<div className="hide">
10+
11+
## 在 Flashduty On-call
12+
---
13+
您可通过以下两种方式获取集成推送地址,任选其一即可。
14+
15+
### 使用专属集成
16+
17+
1. 进入 Flashduty 控制台,选择 **协作空间**,打开一个协作空间
18+
2. 选择 **集成数据**,点击 **添加一个集成**
19+
3. 选择 **New Relic**,点击 **保存**
20+
4. 打开生成的集成卡片,复制 **推送地址**
21+
22+
### 使用共享集成
23+
24+
1. 进入 Flashduty 控制台,选择 **集成中心 → 告警事件**
25+
2. 选择 **New Relic**,填写集成名称
26+
3. 配置默认路由并选择协作空间;创建后可在 **路由** 中增加更多规则
27+
4. 点击 **保存**,复制生成的 **推送地址**
28+
29+
</div>
30+
31+
## 在 New Relic 中配置
32+
---
33+
34+
<Steps>
35+
<Step title="创建 Webhook Destination">
36+
37+
1. 登录 New Relic,进入 **Alerts → Enrich and Notify → Destinations**
38+
2. 创建一个 **Webhook** Destination
39+
3. 名称可填写 `Flashduty`
40+
4. 将 Flashduty 集成的完整推送地址粘贴到 Endpoint URL
41+
42+
</Step>
43+
44+
<Step title="创建 Workflow">
45+
46+
1. 进入 **Alerts → Enrich and Notify → Workflows**,点击创建 Workflow
47+
2. 设置 Issue 过滤条件,选择需要发送到 Flashduty 的 Policy、Condition、实体或标签
48+
3. 添加刚创建的 Webhook Destination
49+
4. 在通知触发器中至少启用 **Activated** 和 **Closed**
50+
5. 建议同时启用 **Priority changed** 和 **Other updates**,以同步等级变化、Alert Event 增减及 Issue 合并后的最新快照
51+
52+
</Step>
53+
54+
<Step title="配置 Payload">
55+
56+
将 Webhook 的自定义 Payload 替换为:
57+
58+
```json
59+
{
60+
"issue_id": "{{issueId}}",
61+
"issue_url": {{json issuePageUrl}},
62+
"title": {{json issueTitle}},
63+
"description": {{json accumulations.conditionDescription.[0]}},
64+
"priority": "{{priority}}",
65+
"state": "{{state}}",
66+
"trigger_event": "{{triggerEvent}}",
67+
"is_correlated": {{isCorrelated}},
68+
"account_id": {{nrAccountId}},
69+
"incident_ids": {{json incidentIds}},
70+
"sources": {{json accumulations.sources}},
71+
"policy_names": {{json accumulations.policyName}},
72+
"condition_names": {{json accumulations.conditionName}},
73+
"entity_names": {{json entitiesData.names}},
74+
"entity_ids": {{json entitiesData.ids}},
75+
"workflow_name": {{json workflowName}}
76+
}
77+
```
78+
79+
<Warning>
80+
请保留 `issue_id`、`state` 和 `priority`。缺少 `issue_id` 时 Flashduty 会拒绝请求,因为随机 Key 无法保证后续更新和关闭命中同一条告警。
81+
</Warning>
82+
83+
</Step>
84+
85+
<Step title="验证生命周期">
86+
87+
让 Alert Condition 进入阈值,确认 Flashduty 收到活动告警;提高优先级或产生新的 Alert Event,确认同一条告警收到更新;最后让 Issue 关闭,确认原告警恢复。
88+
89+
New Relic 的测试通知只能验证 Webhook 可达。Alert Key、更新和恢复必须通过真实 Issue 生命周期验证。
90+
91+
</Step>
92+
</Steps>
93+
94+
## Alert Key 与 Issue 合并
95+
---
96+
97+
Flashduty 直接使用 `issue_id`(New Relic 变量 `issueId`)作为 Alert Key。标题、优先级、Policy、Condition、实体和 `incident_ids` 的变化都不会改变 Alert Key。
98+
99+
`incident_ids` 是当前 Issue 聚合的 Alert Event ID 列表,只作为详情标签。它不能作为 Alert Key,否则一个 Alert Event 加入、关闭或相关性计算变化时会拆出新告警。
100+
101+
当 `trigger_event=MERGE_REQUEST` 时,Flashduty 将请求视为合并后目标 Issue 的一次普通更新,并继续使用 Payload 中的 `issue_id`。当前版本不调用 Flashduty 内部的告警合并能力,也不会推断或关闭来源 Issue。
102+
103+
## 状态和告警等级
104+
---
105+
106+
恢复只根据 `state` 判断,与 `trigger_event` 和等级映射相互独立。
107+
108+
| New Relic 值 | Flashduty 状态或等级 |
109+
| :--- | :--- |
110+
| `state = CLOSED` | 恢复 |
111+
| `state = CREATED`、`ACTIVATED` | 活动告警 |
112+
| `priority = CRITICAL` | Critical |
113+
| `priority = HIGH` | Warning |
114+
| `priority = MEDIUM`、`LOW` | Info |
115+
| `priority` 为空或未知 | Warning |
116+
117+
New Relic 的 Warning 阈值会生成 `HIGH` 优先级 Alert Event,因此 `HIGH` 映射为 Flashduty Warning。如需其他映射,可通过[告警处理 Pipeline](/zh/on-call/integration/alert-integration/alert-pipelines)调整。
118+
119+
## 增加自定义标签
120+
---
121+
122+
如果需要传递更多 Workflow 变量,在默认 Payload 顶层增加 `custom_labels`:
123+
124+
```json
125+
{
126+
"issue_id": "{{issueId}}",
127+
"title": {{json issueTitle}},
128+
"priority": "{{priority}}",
129+
"state": "{{state}}",
130+
"custom_labels": {
131+
"team": {{json accumulations.tag.team.[0]}},
132+
"environment": {{json accumulations.tag.environment.[0]}},
133+
"muting_state": "{{mutingState}}",
134+
"open_alert_events": {{openIncidentsCount}}
135+
}
136+
}
137+
```
138+
139+
- `custom_labels` 最多包含 50 个条目,key 建议使用 snake_case
140+
- 字符串、数字、布尔值、数组和对象都可接收;数组和对象会保存为 JSON 字符串
141+
- 空值不会生成标签;基础字段优先,同名自定义标签不能覆盖基础标签
142+
- 单次请求包含基础标签在内,最多生成 50 个标签
143+
- 不要传递 API Key、Token、密码、Cookie 或其他敏感信息
144+
145+
## 排查问题
146+
---
147+
148+
- **只收到测试通知,真实告警没有通知**:确认 Workflow 已启用,并且过滤条件能够命中真实 Issue
149+
- **Flashduty 返回参数错误**:确认 Payload 是有效 JSON,且包含非空的 `issue_id` 和支持的 `state`
150+
- **告警没有恢复**:确认 Destination 启用了 **Closed**,关闭 Payload 仍携带与激活时相同的 `issue_id`
151+
- **等级或合并变化没有更新**:启用 **Priority changed** 和 **Other updates**
152+
- **部分列表为空**:不同 Condition 和 Issue 类型提供的上下文不同,Flashduty 会忽略空标签
153+
154+
字段含义和可用变量请参阅 [New Relic Workflow variables](https://docs.newrelic.com/docs/alerts/get-notified/custom-variables-alert-event-workflows/)。

0 commit comments

Comments
 (0)