Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

telegraf

БесплатноБез исполняемых скриптовНе проверен

Configure Telegraf as a metrics collection agent for infrastructure and application monitoring. Use when a user needs to collect system metrics, set up input…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Telegraf

Overview

Set up Telegraf to collect, process, and forward metrics from systems, databases, and applications. Covers input/output plugin configuration, metric filtering, aggregation processors, and deployment patterns.

Two behaviours matter on current releases (1.38 and later):

  • Strict environment-variable handling is the default. $VAR and ${VAR} are substituted only inside quoted string values; a variable that is not set is not reported: ${NAME} stays as literal text (or the value ends up empty), so write ${NAME:?NAME is required} for anything mandatory, and a literal $ must be written $$. Start with --non-strict-env-handling only as a stop-gap.
  • fieldpass/fielddrop are deprecated. Use fieldinclude/fieldexclude; namepass, namedrop, tagpass, taginclude and friends are unchanged.

Install with the vendor's apt/yum repository (package telegraf, config in /etc/telegraf/) or run the telegraf Docker image (see Task F). Validate before every deploy:

telegraf --config /etc/telegraf/telegraf.conf --config-directory /etc/telegraf/telegraf.d --test   # one gather, prints line protocol, writes nothing

Instructions

Task A: Basic System Metrics Collection

# /etc/telegraf/telegraf.conf — Collect system metrics and send to InfluxDB
[global_tags]
  environment = "production"
  region = "us-east-1"

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  flush_interval = "10s"
  hostname = ""
  omit_hostname = false
  skip_processors_after_aggregators = true   # do not re-run processors on aggregator output

outputs.influxdb_v2
  urls = ["http://influxdb:8086"]
  token = "${INFLUX_TOKEN:?INFLUX_TOKEN is required}"   # set in /etc/default/telegraf or the unit environment
  organization = "myorg"
  bucket = "infrastructure"

inputs.cpu
  percpu = true
  totalcpu = true
  collect_cpu_time = false

inputs.mem
inputs.disk
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]

inputs.diskio
inputs.net
  interfaces = ["eth0", "ens5"]

inputs.system
inputs.processes
inputs.kernel

Task B: Application and Database Inputs

# /etc/telegraf/telegraf.d/databases.conf — Database monitoring inputs
inputs.postgresql
  address = "postgres://telegraf:${PG_PASSWORD}@localhost:5432/myapp?sslmode=disable"
  databases = ["myapp"]
  [inputs.postgresql.tags]
    service = "postgres"

inputs.mysql
  servers = ["telegraf:${MYSQL_PASSWORD}@tcp(localhost:3306)/"]
  metric_version = 2
  gather_table_schema = true
  gather_process_list = true
  gather_replica_status = true
  [inputs.mysql.tags]
    service = "mysql"

inputs.redis
  servers = ["tcp://localhost:6379"]
  password = "$REDIS_PASSWORD"
  [inputs.redis.tags]
    service = "redis"

inputs.nginx                    # needs ngx_http_stub_status_module enabled
  urls = ["http://localhost:8080/nginx_status"]
  [inputs.nginx.tags]
    service = "nginx"
# /etc/telegraf/telegraf.d/docker.conf — Container metrics
inputs.docker
  endpoint = "unix:///var/run/docker.sock"
  gather_services = false
  container_name_include = []
  perdevice_include = ["cpu"]
  total_include = ["cpu", "blkio", "network"]
  [inputs.docker.tags]
    input = "docker"

Task C: Prometheus Input/Output

# /etc/telegraf/telegraf.d/prometheus.conf — Scrape Prometheus endpoints
inputs.prometheus
  urls = [
    "http://app-server:8080/metrics",
    "http://payment-service:8080/metrics",
  ]
  metric_version = 2
  url_tag = "scrape_url"

# Expose metrics as Prometheus endpoint for Prometheus to scrape
outputs.prometheus_client
  listen = ":9273"
  metric_version = 2
  export_timestamp = true

Task D: Metric Processing and Filtering

Filter at the plugin that produces the metric whenever you can; it is cheaper than dropping later. namepass on a processor only restricts which metrics that processor touches, the rest still flow on.

# /etc/telegraf/telegraf.d/processing.conf — Filter and transform metrics

# Drop noisy fields at the input (add this to the Task A inputs.disk instead of a second
# inputs.disk block, which would collect every disk twice)
inputs.disk
  fieldexclude = ["inodes_*"]

# Drop whole metrics from the stream (processors.filter, Telegraf 1.29+)
processors.filter
  order = 1
  default = "pass"
  processors.filter.rule
    name = ["docker_container_blkio"]
    action = "drop"

processors.converter
  order = 2
  [processors.converter.fields]
    float = ["usage_idle", "usage_user", "usage_system"]

# Tag metrics based on field values
processors.starlark
  order = 3
  namepass = ["cpu"]
  source = '''
def apply(metric):
    idle = metric.fields.get("usage_idle")
    if idle != None:
        used = 100 - idle
        if used > 90:
            metric.tags["cpu_alert"] = "critical"
Полный SKILL.md на GitHub

Установить telegraf в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл telegraf?

Configure Telegraf as a metrics collection agent for infrastructure and application monitoring. Use when a user needs to collect system metrics, set up input plugins for databases and services, configure output to InfluxDB or Prometheus, or build custom metric pipelines.

Как установить скилл telegraf?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл telegraf запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить telegraf с