sensu.endpoint() 函数
sensu.endpoint()
是用户贡献的函数,由包作者维护。
sensu.endpoint()
使用表格行中的数据向 Sensu Events API 发送事件。
用法
sensu.endpoint()
是一个工厂函数,输出另一个函数。输出函数需要 mapFn
参数。
mapFn
一个构建用于生成 POST 请求的对象的函数。需要 r
参数。
mapFn
接受一个表格行 (r
) 并返回一个对象,该对象必须包含以下字段
checkName
text
status
有关更多信息,请参阅 sensu.event()
参数。
函数类型签名
(
apiKey: string,
url: string,
?entityName: string,
?handlers: A,
?namespace: string,
) => (
mapFn: (r: B) => {C with text: E, status: D, checkName: string},
) => (<-tables: stream[B]) => stream[{B with _sent: string}] where D: Equatable
有关更多信息,请参阅 函数类型签名。
参数
url
(必需) Sensu API 的基本 URL,不带尾部斜杠。示例:http://localhost:8080
。
apiKey
(必需) Sensu API 密钥。
handlers
要执行的 Sensu 处理程序。默认为 []
。
namespace
Sensu 命名空间。默认为 default
。
entityName
事件源。默认为 influxdb
。
使用字母数字字符、下划线 (_
)、句点 (.
) 和连字符 (-
)。所有其他字符都将替换为下划线。
示例
向 Sensu 发送严重状态事件
import "influxdata/influxdb/secrets"
import "contrib/sranka/sensu"
token = secrets.get(key: "TELEGRAM_TOKEN")
endpoint = sensu.endpoint(url: "http://localhost:8080", apiKey: apiKey)
crit_statuses =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_statuses
|> endpoint(mapFn: (r) => ({checkName: "critStatus", text: "Status is critical", status: 2}))()
此页是否对您有帮助?
感谢您的反馈!