pagerduty.sendEvent() 函数
pagerduty.sendEvent()
向 PagerDuty 发送事件并返回请求的 HTTP 响应代码。
函数类型签名
(
class: A,
client: B,
clientURL: C,
dedupKey: D,
eventAction: E,
group: F,
routingKey: G,
severity: H,
source: I,
summary: string,
timestamp: J,
?component: K,
?customDetails: L,
?pagerdutyURL: string,
) => int where L: Equatable
有关更多信息,请参阅 函数类型签名。
参数
pagerdutyURL
PagerDuty 端点 URL。
默认为 https://events.pagerduty.com/v2/enqueue。
routingKey
(必需) 从您的 PagerDuty 集成生成的路由密钥。
client
(必需) 发送警报的客户端名称。
clientURL
(必需) 发送警报的客户端 URL。
dedupKey
(必需) 每个警报的 ID,用作重复数据删除密钥,并允许您确认或更改先前消息的严重性。最多支持 255 个字符。
class
(必需) 事件的类别或类型。
类别是用户定义的。例如,ping failure
或 cpu load
。
group
(必需) PagerDuty 使用的逻辑分组。
组是用户定义的。例如,app-stack
。
severity
(必需) 事件的严重性。
有效值
critical
error
warning
info
eventAction
(必需) 要发送到 PagerDuty 的事件类型。
有效值
trigger
resolve
acknowledge
source
(必需) 受影响系统的唯一位置。例如,主机名或完全限定域名 (FQDN)。
component
负责事件的组件。
summary
(必需) 事件的简短文本摘要,用作相关警报的摘要或标题。允许的最大长度为 1024 个字符。
timestamp
(必需) 检测到的事件发生的时间,采用 RFC3339nano 格式。
customDetails
包含有关事件的其他详细信息的记录。
示例
向 PagerDuty 发送事件
import "pagerduty"
import "pagerduty"
pagerduty.sendEvent(
routingKey: "example-routing-key",
client: "example-client",
clientURL: "http://example-url.com",
dedupKey: "example-dedup-key",
class: "example-class",
eventAction: "trigger",
group: "example-group",
severity: "crit",
component: "example-component",
source: "example-source",
summary: "example-summary",
timestamp: now(),
customDetails: {"example-key": "example value"},
)
此页面是否对您有帮助?
感谢您的反馈!