docker-log-driver-telegram

command module
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 31 Imported by: 0

README

Telegram Log Driver

pkg-img version-img license-img

Docker logging driver that forwards container logs to Telegram chats via a bot.

Quick Start

# Install plugin
docker plugin install sklyarx/docker-log-driver-telegram:latest --alias telegram --grant-all-permissions

# Run container with the driver
docker run --log-driver=telegram \
  --log-opt token="<bot_token>" \
  --log-opt chat_id="<chat_id>" \
  your_image

Installation

Plugin Management
# Install
docker plugin install sklyarx/docker-log-driver-telegram:latest --alias telegram --grant-all-permissions

# Upgrade
docker plugin disable telegram --force
docker plugin upgrade telegram sklyarx/docker-log-driver-telegram:latest --grant-all-permissions
docker plugin enable telegram
systemctl restart docker

# Uninstall
docker plugin disable telegram --force
docker plugin rm telegram
Plugin Environment
docker plugin disable telegram --force
docker plugin set telegram ENV=production LOG_LEVEL=info
docker plugin enable telegram
Variable Default Description
ENV development Plugin runtime environment: production or development
LOG_LEVEL info Plugin log level: debug, info, warn, error, fatal, or panic

Configuration

Container Level

Use with docker run:

docker run --log-driver=telegram \
    --log-opt token="<bot_token>" \
    --log-opt chat_id="<chat_id>" \
    --log-opt template="{container_name}: {log}" \
    your_image

Use with docker-compose.yml:

version: '3.8'
services:
  app:
    image: your/image
    logging:
      driver: telegram
      options:
        token: "<bot_token>"
        chat_id: "<chat_id>"
        template: "{container_name}: {log}"
Daemon Level (Default for All Containers)

Edit /etc/docker/daemon.json:

{
  "log-driver": "telegram",
  "log-opts": {
    "token": "<bot_token>",
    "chat_id": "<chat_id>"
  }
}

Restart Docker after changes: systemctl restart docker

Options

Option Required Default Description
url No https://api.telegram.org Telegram API URL
token Yes Bot API token
chat_id Yes Target chat ID
template No {log} Message format template
filter-regex No Regex to filter logs
retries No 5 Retry attempts after the initial request (0 = no retries)
timeout No 10s API request timeout (units: ns, us/µs, ms, s, m, h)
no-file No false Disable log files (disables docker logs)
keep-file No false Keep log files after container stop
mode No blocking Log processing mode: blocking/non-blocking
max-buffer-size No 1000000 Max buffer size (Example values: 32, 32b, 32B, 32k, 32K, 32kb, 32Kb, 32Mb, 32Gb, 32Tb, 32Pb)
batch-enabled No true Enable batch sending
batch-flush-interval No 3s Batch flush interval (units: ns, us/µs, ms, s, m, h)

filter-regex sends only log messages that match the regex.

Template Tags

To customize the log message format using the template option, you can use the following tags:

Tag Description
{log} Log message
{timestamp} Log timestamp
{container_id} Short container ID
{container_full_id} Full container ID
{container_name} Container name
{image_id} Short image ID
{image_full_id} Full image ID
{image_name} Image name
{daemon_name} Docker daemon name

Extra attributes populated by Docker from labels, labels-regex, env, and env-regex can also be used as template tags.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL