认证
此提供商需要身份验证。
- host_url: Icinga2 主机 URL(必需:True,敏感:False)
- api_user: Icinga2 API 用户(必需:True,敏感:False)
- api_password: Icinga2 API 密码(必需:True,敏感:True)
某些范围可能需要才能通过提供商执行特定操作或查询。以下是相关范围及其用例的摘要:
- read_alerts: 从 Icinga2 读取警报
在工作流中
此提供商不能用作工作流中的"步骤"或"操作"。如果您想使用它,请通过在 GitHub 仓库 创建问题告诉我们。
Icinga2 Provider
Icinga2 provider 允许您在 Keep 中接收来自 Icinga2 监控系统的告警。 Icinga2 provider 支持 2 种接收告警的方法:Webhooks 和 API 轮询。
接收告警的推荐和主要方法是通过 Webhooks。
设置
先决条件
- 访问 Icinga2 实例。
- 具有相关权限的 API 用户。
- 具有 webhook 功能的 Keep 实例。
配置
Provider 需要以下配置:
yaml
authentication:
host_url: "https://icinga2.example.com" # 您的 Icinga2 实例 URL
api_user: "your-api-user" # Icinga2 API 用户名
api_password: "your-api-password" # Icinga2 API 密码Webhook 配置
要配置 Icinga2 通过 webhooks 发送告警到 Keep:
- 导航到您的 Icinga2 配置目录。
- 创建或编辑
eventcommands.conf文件。 - 添加以下事件命令配置:
plaintext
object EventCommand "keep-notification" {
command = [ "curl" ]
arguments = {
"-X" = "POST"
"-H" = "Content-Type: application/json"
"-H" = "X-API-KEY: ${keep_api_key}"
"--data" = "{
\"host\": {
\"name\": \"$host.name$\",
\"display_name\": \"$host.display_name$\",
\"check_command\": \"$host.check_command$\",
\"acknowledgement\": \"$host.acknowledgement$\",
\"downtime_depth\": \"$host.downtime_depth$\",
\"flapping\": \"$host.flapping$\"
},
\"service\": {
\"name\": \"$service.name$\",
\"display_name\": \"$service.display_name$\",
\"check_command\": \"$service.check_command$\",
\"acknowledgement\": \"$service.acknowledgement$\",
\"downtime_depth\": \"$service.downtime_depth$\",
\"flapping\": \"$service.flapping$\"
},
\"check_result\": {
\"exit_status\": \"$service.state$\",
\"state\": \"$service.state_text$\",
\"output\": \"$service.output$\",
\"execution_start\": \"$service.last_check$\",
\"execution_end\": \"$service.last_check$\",
\"state_type\": \"$service.state_type$\",
\"attempt\": \"$service.check_attempt$\",
\"execution_time\": \"$service.execution_time$\",
\"latency\": \"$service.latency$\"
}
}"
"${keep_webhook_url}" = {
required = true
}
}
}- 在您的 Icinga2 配置中定义变量:
keep_api_key:具有 webhook 角色的 Keep API 密钥。keep_webhook_url:您的 Keep Webhook URL。
- 创建使用此事件命令的通知规则。
- 重启 Icinga2 以应用更改。
状态映射
默认情况下,Icinga2 状态会自动映射到 Keep 告警严重性和状态,如下所示: