文档文档

victorops.endpoint() 函数

victorops.endpoint() 是用户贡献的函数,由 软件包作者 维护。

victorops.endpoint() 使用来自输入行的数据向 VictorOps 发送事件。

用法

victorops.endpoint 是一个工厂函数,它输出另一个函数。输出函数需要 mapFn 参数。

mapFn

一个构建用于生成 POST 请求的对象的函数。需要 r 参数。

mapFn 接受表行 (r) 并返回一个对象,该对象必须包含以下字段

  • monitoringTool
  • messageType
  • entityID
  • entityDisplayName
  • stateMessage
  • timestamp

有关更多信息,请参阅 victorops.event() 参数。

函数类型签名
(
    url: string,
    ?monitoringTool: A,
) => (
    mapFn: (
        r: B,
    ) => {
        C with
        timestamp: H,
        stateMessage: G,
        messageType: F,
        entityID: E,
        entityDisplayName: D,
    },
) => (<-tables: stream[B]) => stream[{B with _sent: string}]

有关更多信息,请参阅 函数类型签名

参数

url

(必需) VictorOps REST 端点集成 URL。

示例:https://alert.victorops.com/integrations/generic/00000000/alert/<api_key>/<routing_key><api_key><routing_key> 替换为有效的 VictorOps API 密钥和路由密钥。

monitoringTool

用于监控的工具。默认为 InfluxDB

示例

向 VictorOps 发送关键事件

import "contrib/bonitoo-io/victorops"
import "influxdata/influxdb/secrets"

apiKey = secrets.get(key: "VICTOROPS_API_KEY")
routingKey = secrets.get(key: "VICTOROPS_ROUTING_KEY")
url = "https://alert.victorops.com/integrations/generic/00000000/alert/${apiKey}/${routingKey}"
endpoint = victorops.endpoint(url: url)

crit_events =
    from(bucket: "example-bucket")
        |> range(start: -1m)
        |> filter(fn: (r) => r._measurement == "statuses" and status == "crit")

crit_events
    |> endpoint(
        mapFn: (r) =>
            ({
                monitoringTool: "InfluxDB",
                messageType: "CRITICAL",
                entityID: "${r.host}-${r._field}-critical",
                entityDisplayName: "Critical alert for ${r.host}",
                stateMessage: "${r.host} is in a critical state. ${r._field} is ${string(
                        v: r._value,
                    )}.",
                timestamp: now(),
            }),
    )()

此页内容对您有帮助吗?

感谢您的反馈!


Flux 的未来

Flux 将进入维护模式。您可以继续像目前一样使用它,而无需对代码进行任何更改。

阅读更多

现已全面上市

InfluxDB 3 Core 和 Enterprise

快速启动。更快扩展。

获取更新

InfluxDB 3 Core 是一个开源、高速、最近数据引擎,可实时收集和处理数据,并将其持久化到本地磁盘或对象存储。InfluxDB 3 Enterprise 构建在 Core 的基础上,增加了高可用性、读取副本、增强的安全性以及数据压缩,从而加快查询速度并优化存储。InfluxDB 3 Enterprise 的免费层可供非商业家庭或业余爱好者使用。

有关更多信息,请查看