sensu.event() 函数
sensu.event()
是用户贡献的函数,由包作者维护。
sensu.event()
向 Sensu Events API 发送单个事件。
函数类型签名
(
apiKey: string,
checkName: string,
text: A,
url: string,
?entityName: string,
?handlers: B,
?namespace: string,
?state: string,
?status: C,
) => int where C: Equatable
有关更多信息,请参阅函数类型签名。
参数
url
(必需) Sensu API 的基本 URL,不带尾部斜杠。
示例:http://localhost:8080
apiKey
(必需) Sensu API 密钥。
checkName
(必需) 检查名称。
使用字母数字字符、下划线 (_
)、句点 (.
) 和连字符 (-
)。所有其他字符都将替换为下划线。
text
(必需) 事件文本。
映射到 Sensu Events API 请求中的 output
。
handlers
要执行的 Sensu 处理程序。默认为 []
。
status
指示状态的事件状态代码。默认为 0
。
状态代码 | 状态 |
---|---|
0 | 0 |
1 | 警告 |
2 | 严重 |
任何其他值 | 未知或自定义状态 |
state
事件状态。对于 0
状态,默认为 "passing"
;对于其他状态,默认为 "failing"
。
接受的值:
"failing"
"passing"
"flapping"
namespace
Sensu 命名空间。默认为 "default"
。
entityName
事件源。默认为 influxdb
。
使用字母数字字符、下划线 (_
)、句点 (.
) 和连字符 (-
)。所有其他字符都将替换为下划线。
示例
将上次报告的状态发送到 Sensu
import "influxdata/influxdb/secrets"
import "contrib/sranka/sensu"
apiKey = secrets.get(key: "SENSU_API_KEY")
lastReported =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses")
|> last()
|> findRecord(fn: (key) => true, idx: 0)
sensu.event(
url: "http://localhost:8080",
apiKey: apiKey,
checkName: "diskUsage",
text: "Disk usage is **${lastReported.status}**.",
)
此页内容是否对您有帮助?
感谢您的反馈!