InfluxDB Docs

discord.send() function

The discord.send() function sends a single message to a Discord channel using a Discord webhook.

Function type: Output

import "contrib/chobbs/discord"

discord.send(
  webhookToken: "mySuPerSecRetTokEn",
  webhookID: "123456789",
  username: "username",
  content: "This is an example message",
  avatar_url: "https://example.com/avatar_pic.jpg"
)

Parameters

webhookToken

Discord webhook token.

Data type: String

webhookID

Discord webhook ID.

Data type: String

username

Override the Discord webhook’s default username.

Data type: String

content

Message to send to Discord (2000 character limit).

Data type: String

avatar_url

Override the Discord webhook’s default avatar.

Data type: String

Examples

Send the last reported status to Discord
import "contrib/chobbs/discord"
import "influxdata/influxdb/secrets"

token = secrets.get(key: "DISCORD_TOKEN")

lastReported =
  from(bucket: "example-bucket")
    |> range(start: -1m)
    |> filter(fn: (r) => r._measurement == "statuses")
    |> last()
    |> findRecord(fn: (key) => true, idx: 0)

discord.send(
  webhookToken:token,
  webhookID: "1234567890",
  username: "chobbs",
  content: "The current status is \"${lastReported.status}\".",
  avatar_url: "https://staff-photos.net/pic.jpg"
)

Package author and maintainer

Github: @chobbs
InfluxDB Slack: @craig


New! Cloud or OSS?