servicenow.endpoint() 函数
servicenow.endpoint()
是用户贡献的函数,由包作者维护。
servicenow.endpoint()
使用来自输入行的数据向 ServiceNow 发送事件。
用法
servicenow.endpoint
是一个工厂函数,输出另一个函数。输出函数需要 mapFn
参数。
mapFn
一个构建用于生成 ServiceNow API 请求的对象的函数。需要 r
参数。
mapFn
接受表行 (r
) 并返回一个对象,该对象必须包含以下属性
描述
严重性
来源
节点
指标类型
资源
指标名称
消息键
附加信息
有关更多信息,请参阅 servicenow.event()
参数。
函数类型签名
(
password: string,
url: string,
username: string,
?source: A,
) => (
mapFn: (
r: B,
) => {
C with
severity: J,
resource: I,
node: H,
metricType: G,
metricName: F,
messageKey: E,
description: D,
},
) => (<-tables: stream[B]) => stream[{B with _sent: string}] where J: Equatable
有关更多信息,请参阅 函数类型签名。
参数
url
(必需) ServiceNow Web 服务 URL。
username
(必需) 用于 HTTP BASIC 身份验证的 ServiceNow 用户名。
password
(必需) 用于 HTTP BASIC 身份验证的 ServiceNow 密码。
来源
源名称。默认为 "Flux"
。
示例
向 ServiceNow 发送严重事件
import "contrib/bonitoo-io/servicenow"
import "influxdata/influxdb/secrets"
username = secrets.get(key: "SERVICENOW_USERNAME")
password = secrets.get(key: "SERVICENOW_PASSWORD")
endpoint =
servicenow.endpoint(
url: "https://example-tenant.service-now.com/api/global/em/jsonv2",
username: username,
password: password,
)
crit_events =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_events
|> endpoint(
mapFn: (r) =>
({
node: r.host,
metricType: r._measurement,
resource: r.instance,
metricName: r._field,
severity: "critical",
additionalInfo: {"devId": r.dev_id},
}),
)()
此页面是否对您有帮助?
感谢您的反馈!