文档文档

teams.endpoint() 函数

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

teams.endpoint() 使用表行中的数据向 Microsoft Teams 频道发送消息。

用法

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

mapFn

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

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

  • title
  • text
  • summary

有关更多信息,请参阅 teams.message 参数。

函数类型签名
(
    url: string,
) => (
    mapFn: (r: A) => {B with title: C, text: string, summary: string},
) => (<-tables: stream[A]) => stream[{A with _sent: string}]

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

参数

url

(必填) 入站 webhook URL。

示例

向 Microsoft Teams 频道发送关键状态

import "contrib/sranka/teams"

url = "https://outlook.office.com/webhook/example-webhook"
endpoint = teams.endpoint(url: url)

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

crit_statuses
    |> endpoint(
        mapFn: (r) =>
            ({
                title: "Disk Usage",
                text: "Disk usage is: **${r.status}**.",
                summary: "Disk usage is ${r.status}",
            }),
    )()

此页是否对您有帮助?

感谢您的反馈!


Flux 的未来

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

阅读更多

现已全面上市

InfluxDB 3 Core 和 Enterprise

快速启动。更快扩展。

获取更新

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

有关更多信息,请查看