telegram.endpoint() function
The telegram.endpoint()
function sends a message to a Telegram channel using data from table rows.
*Function type: Output*
For information about retrieving your Telegram bot token and channel ID, see Set up a Telegram bot.
URL of the Telegram bot endpoint. Default is https://api.telegram.org/bot
.
*Data type: String*
*Data type: String*
of the message text. Default is "MarkdownV2"
.
*Data type: String*
Disable preview of web links in the sent message. Default is false
.
*Data type: Boolean*
A function that builds the object used to generate the POST request. Requires an r
parameter.
*Data type: Function*
mapFn
accepts a table row (r
) and returns an object that must include the following fields:
text
silent
For more information, see telegram.message()
parameters.
Send critical statuses to a Telegram channel
import "influxdata/influxdb/secrets"
import "contrib/sranka/telegram"
token = secrets.get(key: "TELEGRAM_TOKEN")
endpoint = telegram.endpoint(token: token)
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_statuses
|> endpoint(mapFn: (r) => ({
channel: "-12345",
text: "Disk usage is **${r.status}**.",
silent: true
})
Package author and maintainer
Github:
InfluxDB Slack: @sranka