servicenow.endpoint() 函数
servicenow.endpoint() 是一个由 package author 维护的用户贡献函数。
servicenow.endpoint() 将事件发送到 ServiceNow,使用输入行中的数据。
用法
servicenow.endpoint 是一个工厂函数,它输出另一个函数。输出函数需要一个 mapFn 参数。
映射函数
一个构建用于生成ServiceNow API请求的对象的函数。需要一个 r 参数。
mapFn 接受一个表格行 (r) 并返回一个必须包含以下属性的对象:
descriptionseveritysourcenodemetricTyperesourcemetricNamemessageKeyadditionalInfo
欲了解更多信息,请参阅 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
有关更多信息,请参见 Function type signatures。
参数
网址
(必填) ServiceNow web 服务 URL。
用户名
(必填) 用于HTTP BASIC身份验证的ServiceNow用户名。
密码
(必填) 用于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},
}),
)()