New Relic是一个基于云计算的可观测平台,旨在帮助您更好地构建应用。您可以通过New Relic整合数据、分析数据及快速响应事件。您只需在New Relic控制台上配置通知渠道为日志服务开放告警接口的URL,即可将New Relic告警消息发送到日志服务告警系统中,由日志服务告警系统完成告警降噪、通知等处理。
New Relic配置
- 登录New Relic管理控制台。
- 配置通知渠道。
- 应用通知渠道。
- 在顶部导航栏,选择 。
- 在告警规则列表中,单击目标告警规则。
- 在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告警消息被接入到日志服务后,映射为日志服务告警内容。示例如下:
{
"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"
}
日志服务 | 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字段中,如果元素的值不是字符串,则对应的键值对将被删除,剩余键值对被添加到日志服务告警消息的fire_results字段中。 |
fire_results_count | 无 | 统计fire_results字段中元素的个数。 |
fire_time | fire_time | 告警触发时间。 |
resolve_time | resolve_time | 告警恢复时间。
|
labels | labels | 标签信息。
|
annotations | annotations | 标注信息。日志服务告警消息的annotations字段中将加入以下字段:
|
severity | severity | 告警严重度。New Relic告警严重度与日志服务告警严重度的映射关系如下:
说明 如果New Relic告警中未定义严重度,则日志服务告警严重度映射为中。
|
policy | 无 | 您在开放告警应用中配置的告警策略。更多信息,请参见Policy结构。 |
project | 无 | 告警中心所属的Project。更多信息,请参见项目(Project)。 |
drill_down_query | drill_down_query | 对应New Relic告警事件管理页面的URL地址。 |