New Relic是一個雲端式計算的可觀測平台,旨在協助您更好地構建應用。您可以通過New Relic整合資料、分析資料及快速響應事件。您只需在New Relic控制台上配置通知渠道為Log Service開放警示介面的URL,即可將New Relic警示訊息發送到Log Service警示系統中,由Log Service警示系統完成警示降噪、通知等處理。
New Relic配置
- 登入New Relic管理主控台。
- 配置通知渠道。
- 在頂部導覽列,選擇。
- 單擊New notification channel。
- 配置如下參數。
參數 說明 Select a channel type 通知渠道類型,選擇Webhook。 Channel name 通知渠道名稱。 Base Url 配置為您在Log Service中建立開放警示服務和應用後產生的介面資訊(完整URL)。如何擷取,請參見擷取介面資訊。 Use Custom Payload 定義警示訊息的內容,New Relic將根據此配置產生警示訊息內容。關於New Relic提供的警示訊息變數的更多資訊,請參見New Relic官方文檔。 您需要將Payload中的內容替換為如下內容。其中,除labels欄位和annotations欄位之外的所有欄位必須按照樣本進行配置。其餘未被使用的New Relic變數,您可以根據需求添加到labels欄位或annotations欄位中。
{ "alert_instance_id": "$INCIDENT_ID", "alert_name": "$POLICY_NAME", "status": "$EVENT_STATE", "alert_time": "$TIMESTAMP", "fire_time": "$TIMESTAMP", "fire_result": "$TARGETS", "resolve_time": "$TIMESTAMP", "labels": { "metadata": "$METADATA" }, "annotations": { "desc": "$EVENT_DETAILS", "__account_id__": "$ACCOUNT_ID", "__account_name__": "$ACCOUNT_NAME", "__link_incident_acknowledge_url__": "$INCIDENT_ACKNOWLEDGE_URL", "__link_policy_url__": "$POLICY_URL", "__link_runbook_url__": "$RUNBOOK_URL", "__link_violation_callback_url__": "$VIOLATION_CALLBACK_URL", "__link_violation_chart_url__": "$VIOLATION_CHART_URL", "closed_violations_count_critical": "$CLOSED_VIOLATIONS_COUNT_CRITICAL", "closed_violations_count_warning": "$CLOSED_VIOLATIONS_COUNT_WARNING", "condition_description": "$DESCRIPTION", "condition_id": "$CONDITION_ID", "condition_name": "$CONDITION_NAME", "duration": "$DURATION", "event_type": "$EVENT_TYPE", "open_violations_count_critical": "$OPEN_VIOLATIONS_COUNT_CRITICAL", "open_violations_count_warning": "$OPEN_VIOLATIONS_COUNT_WARNING", "owner": "$EVENT_OWNER", "timestamp_utc_string": "$TIMESTAMP_UTC_STRING" }, "severity": "$SEVERITY", "drill_down_query": "$INCIDENT_URL" }
- 應用通知渠道。
- 在頂部導覽列,選擇。
- 在警示規則列表中,單擊目標警示規則。
- 在Notification channel頁簽中,單擊Add notification channels。
- 選擇您已建立的通知渠道。
New Relic警示訊息
New Relic警示訊息內容樣本如下:
{
"alert_instance_id": 123456,
"alert_name": "wkbTest",
"alert_time": 1629445629043,
"fire_time": 1629445629043,
"fire_results":
[
{
"id": "Metric",
"name": "cn-hangzhou_ecs.s6-c1m4.xlarge_123456789",
"link": "https://insights.newrelic.com/accounts/123456/query?query=SELECT%20average%28%60host.diskUsedPercent%60%29%20FROM%20Metric%20FACET%20regionId%2C%20host.instanceType%2C%20%20entity.id%20TIMESERIES%201%20minute%20SINCE%20%272021-08-20%2001%3A48%3A08%27%20UNTIL%20%272021-08-20%2007%3A47%3A08%27",
"labels":
{
"entity.id": "123456789",
"host.instanceType": "ecs.s6-c1m4.xlarge",
"regionId": "cn-hangzhou"
},
"product": "NRQL",
"type": "Query"
}
],
"resolve_time": 1629445629043,
"status": "open",
"labels":
{
"metadata":
{
"evaluation_system_source": "Willamette"
}
},
"annotations":
{
"owner": "",
"open_violations_count_critical": 1,
"closed_violations_count_critical": 0,
"__link_policy_url__": "https://alerts.newrelic.com/accounts/123456/policies/123456",
"__link_violation_chart_url__": "https://gorgon.nr-assets.net/image/1a2b3c4d-1234-abcd-1a2b-1a2b3c4d?config.legend.enabled=false",
"condition_id": 123456,
"duration": 476,
"open_violations_count_warning": 0,
"__account_name__": "Account 123456",
"event_type": "INCIDENT",
"__link_runbook_url__": null,
"__link_violation_callback_url__": "https://insights.newrelic.com/accounts/123456/query?query=SELECT%20average%28%60host.diskUsedPercent%60%29%20FROM%20Metric%20FACET%20regionId%2C%20host.instanceType%2C%20%20entity.id%20TIMESERIES%201%20minute%20SINCE%20%272021-08-20%2001%3A48%3A08%27%20UNTIL%20%272021-08-20%2007%3A47%3A08%27",
"timestamp_utc_string": "2021-08-20, 07:47 UTC",
"__account_id__": 123456,
"condition_description": "this is cond0",
"__link_incident_acknowledge_url__": "https://alerts.newrelic.com/accounts/123456/incidents/123456/acknowledge",
"closed_violations_count_warning": 0,
"condition_name": "cond0",
"desc": "Metric query result is > 0.0 on 'cond0'"
},
"severity": "CRITICAL",
"drill_down_query": "https://alerts.newrelic.com/accounts/123456/incidents/123456",
}警示訊息映射
New Relic警示訊息被接入到Log Service後,映射為Log Service警示內容。樣本如下:
{
"aliuid": "aliuid1",
"alert_instance_id": "123456",
"alert_id": "NewRelic_wkbTest",
"alert_type": "sls_pub",
"alert_name": "test-alert",
"region": "{警示中心Project所在的地區}",
"project": "{警示中心所屬的Project}",
"project_id": 0,
"next_eval_interval": 0,
"alert_time": 1629445629,
"fire_time": 1629445629,
"fire_results":
[
{
"id": "Metric",
"link": "https://insights.newrelic.com/accounts/123456/query?query=SELECT%20average%28%60host.diskUsedPercent%60%29%20FROM%20Metric%20FACET%20regionId%2C%20host.instanceType%2C%20%20entity.id%20TIMESERIES%201%20minute%20SINCE%20%272021-08-20%2001%3A48%3A08%27%20UNTIL%20%272021-08-20%2007%3A47%3A08%27",
"name": "cn-hangzhou_ecs.s6-c1m4.xlarge_123456789",
"product": "NRQL",
"type": "Query"
}
],
"fire_results_count": 1,
"resolve_time": 0,
"status": "firing",
"results": null,
"labels":
{
"evaluation_system_source": "Willamette"
},
"annotations":
{
"__account_id__": "123456",
"__account_name__": "Account 123456",
"__config_app__": "sls_pub_alert",
"__link_incident_acknowledge_url__": "https://alerts.newrelic.com/accounts/123456/incidents/123456/acknowledge",
"__link_policy_url__": "https://alerts.newrelic.com/accounts/123456/policies/123456",
"__link_violation_callback_url__": "https://insights.newrelic.com/accounts/123456/query?query=SELECT%20average%28%60host.diskUsedPercent%60%29%20FROM%20Metric%20FACET%20regionId%2C%20host.instanceType%2C%20%20entity.id%20TIMESERIES%201%20minute%20SINCE%20%272021-08-20%2001%3A48%3A08%27%20UNTIL%20%272021-08-20%2007%3A47%3A08%27",
"__link_violation_chart_url__": "https://gorgon.nr-assets.net/image/1a2b3c4d-1234-abcd-1a2b-1a2b3c4d?config.legend.enabled=false",
"__pub_alert_app__": "{開放警示應用ID}",
"__pub_alert_protocol__": "newrelic",
"__pub_alert_region__": "{接收警示訊息的網路介面對應的地區}",
"__pub_alert_service__": "{開放警示服務ID}",
"condition_description": "this is cond0",
"condition_id": "123456",
"condition_name": "cond0",
"desc": "Metric query result is > 0.0 on 'cond0'",
"duration": "476",
"event_type": "INCIDENT",
"open_violations_count_critical": "1",
"timestamp_utc_string": "2021-08-20, 07:47 UTC"
},
"severity": 10,
"policy":
{
"alert_policy_id": "{開放警示應用中配置的警示策略ID}",
"action_policy_id": "{開放警示應用中配置的行動策略ID}",
"use_default": false,
"repeat_interval": "{開放警示應用中配置的重複等待時間}"
},
"template": null,
"drill_down_query": "https://alerts.newrelic.com/accounts/123456/incidents/123456"
}| Log Service | New Relic | 說明 |
| aliuid | 無 | 用於接入警示的開放警示應用所屬的阿里雲帳號ID。 |
| alert_id | 無 | 警示監控規則的ID。 alert_id欄位值為NewRelic_${alert_name},其中{$alert_name}為警示監控規則的名稱。 |
| alert_instance_id | alert_instance_id | 警示訊息的ID。 |
| alert_type | 無 | 警示類型,固定為sls_pub。 |
| alert_name | alert_name | 警示監控規則的名稱。 |
| status | status | 警示狀態。
|
| next_eval_interval | 無 | 警示評估間隔時間,固定為0。 |
| alert_time | alert_time | 警示首次觸發時間。 |
| fire_results | fire_results | 警示的查詢參數和中間結果。欄位值為Array類型。 New Relic警示訊息的fire_results欄位中,如果元素的值不是字串,則對應的索引值對將被刪除,剩餘索引值對被添加到Log Service警示訊息的fire_results欄位中。 |
| fire_results_count | 無 | 統計fire_results欄位中元素的個數。 |
| fire_time | fire_time | 警示觸發時間。 |
| resolve_time | resolve_time | 警示恢復。
|
| labels | labels | 標籤資訊。
|
| annotations | annotations | 標註資訊。Log Service警示訊息的annotations欄位中將加入以下欄位:
|
| severity | severity | 警示嚴重度。New Relic警示嚴重度與Log Service警示嚴重度的映射關係如下:
說明 如果New Relic警示中未定義嚴重度,則Log Service警示嚴重度映射為中。 |
| policy | 無 | 您在開放警示應用中配置的警示策略。更多資訊,請參見Policy結構。 |
| project | 無 | 警示中心所屬的Project。更多資訊,請參見專案(Project)。 |
| drill_down_query | drill_down_query | 對應New Relic警示事件管理頁面的URL地址。 |