PagerDuty 操作
Elastic Stack Serverless
使用 PagerDuty 操作在 PagerDuty 中创建事件。要创建 PagerDuty 事件,您必须在 elasticsearch.yml
中配置至少一个 PagerDuty 帐户。
您在 actions
数组中配置 PagerDuty 操作。特定于操作的属性使用 pagerduty
关键字指定。
以下代码段显示了一个简单的 PagerDuty 操作定义
"actions" : {
"notify-pagerduty" : {
"transform" : { ... },
"throttle_period" : "5m",
"pagerduty" : {
"description" : "Main system down, please check!"
}
}
}
- 消息描述
为了给 PagerDuty 事件提供更多上下文,您可以将有效负载以及上下文数组附加到操作。
"actions" : {
"notify-pagerduty" : {
"throttle_period" : "5m",
"pagerduty" : {
"account" : "team1",
"description" : "Main system down, please check! Happened at {{ctx.execution_time}}",
"attach_payload" : true,
"client" : "/foo/bar/{{ctx.watch_id}}",
"client_url" : "http://www.example.org/",
"contexts" : [
{
"type": "link",
"href": "http://acme.pagerduty.com"
},{
"type": "link",
"href": "http://acme.pagerduty.com",
"text": "View the incident on {{ctx.payload.link}}"
}
]
}
}
}
名称 | 必需 | 描述 |
---|---|---|
account(帐户) |
否 | 要使用的帐户,默认为默认帐户。该帐户需要一个 service_api_key 属性。 |
尽管以下某些属性的名称与 PagerDuty "Events API v1" 参数名称匹配,但最终会通过适当转换属性来使用 "Events API v2" API。
名称 | 必需 | 描述 |
---|---|---|
description(描述) |
是 | 此事件的简要描述 |
event_type(事件类型) |
否 | 要发送的事件类型。必须是 trigger 、resolve 或 acknowledge 之一。默认为 trigger 。 |
incident_key(事件密钥) |
否 | PagerDuty 端的事件密钥,也用于重复数据删除,并允许解决或确认事件。 |
client(客户端) |
否 | 触发事件的客户端名称,例如 Watcher Monitoring |
client_url(客户端 URL) |
否 | 用于访问以获取更多详细信息的客户端 URL。 |
attach_payload(附加有效负载) |
否 | 如果设置为 true ,则有效负载将作为详细信息附加到 API 调用。默认为 false 。 |
contexts(上下文) |
否 | 一个对象数组,允许您提供其他链接或图像,以便为触发器提供更多上下文。 |
proxy.host(代理主机) |
否 | 要使用的代理主机(仅与 proxy.port 结合使用) |
proxy.port(代理端口) |
否 | 要使用的代理端口(仅与 proxy.host 结合使用) |
您可以使用 xpack.notification.pagerduty.event_defaults.*
属性为整个服务配置上述值的默认值,以及使用 xpack.notification.pagerduty.account.your_account_name.event_defaults.*
为每个帐户配置默认值
所有这些对象都支持模板,因此您可以将来自上下文和有效负载的数据用作所有字段的一部分。
名称 | 必需 | 描述 |
---|---|---|
type(类型) |
是 | link 或 image 之一。 |
href |
是/否 | 包含更多信息的链接。如果类型为 link ,则必须存在,如果类型为 image ,则为可选 |
src |
否 | image 类型的 src 属性。 |
您可以在 elasticsearch.yml
的 xpack.notification.pagerduty
命名空间中配置 Watcher 用于与 PagerDuty 通信的帐户。
要配置 PagerDuty 帐户,您需要要将通知发送到的 PagerDuty 服务的 API 集成密钥。要获取密钥
- 以帐户管理员身份登录到 pagerduty.com。
- 转到服务并选择您要定位的 PagerDuty 服务。
- 单击集成选项卡,如果尚不存在,则添加 Events API V2 集成。
- 复制 API 集成密钥以供下面使用。
要在密钥库中配置 PagerDuty 帐户,您必须指定帐户名称和集成密钥(请参阅安全设置)
bin/elasticsearch-keystore add xpack.notification.pagerduty.account.my_pagerduty_account.secure_service_api_key
仍然支持在 YAML 文件中或通过集群更新设置存储服务 API 密钥,但应使用密钥库设置。
您还可以为 PagerDuty 事件属性指定默认值
xpack.notification.pagerduty:
account:
my_pagerduty_account:
event_defaults:
description: "Watch notification"
incident_key: "my_incident_key"
client: "my_client"
client_url: http://www.example.org
event_type: trigger
attach_payload: true
如果您配置了多个 PagerDuty 帐户,则需要设置默认帐户,或者在 pagerduty
操作中指定应使用哪个帐户发送事件。
xpack.notification.pagerduty:
default_account: team1
account:
team1:
...
team2:
...