文档文档

bigpanda.endpoint() 函数

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

bigpanda.endpoint() 使用来自输入行的数据向 BigPanda 发送警报。

用法

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

mapFn

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

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

  • status
  • 要发送到 BigPanda 警报 API 的其他警报参数

有关更多信息,请参阅 bigpanda.sendAlert() 参数。

函数类型签名
(
    appKey: A,
    token: string,
    ?url: string,
) => (mapFn: (r: B) => {C with status: D}) => (<-tables: stream[B]) => stream[{B with _sent: string}]

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

参数

url

BigPanda 警报 API URL。默认为 bigpanda.defaultURL 选项的值。

token

(必需) BigPanda API 授权令牌(API 密钥)

appKey

(必需) BigPanda App Key

示例

向 BigPanda 发送严重警报

import "influxdata/influxdb/secrets"
import "json"

token = secrets.get(key: "BIGPANDA_API_KEY")
endpoint = bigpanda.endpoint(token: token, appKey: "example-app-key")

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

crit_events
    |> endpoint(
        mapFn: (r) => {
            return {r with status: "critical",
                check: "critical-status-check",
                description: "${r._field} is critical: ${string(v: r._value)}",
                tags: json.encode(v: [{"name": "host", "value": r.host}]),
            }
        },
    )()

此页是否对您有帮助?

感谢您的反馈!


Flux 的未来

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

阅读更多

现已全面上市

InfluxDB 3 Core 和 Enterprise

快速启动。更快扩展。

获取更新

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

有关更多信息,请查看