telegraf 配置文件详解
Author: fupeng.li
date: 2020-05-14
关键字:监控系统,telegraf
#全局tag配置,采用key = "values"方式,这样在本机采集到的所有数据将都有这个标签
[global_tags]
dc = "docker-test"
#agent配置
[agent]
#默认的数据(input)采集间隔时间
interval = "1s"
#采用轮询时间间隔。默认是使用interval里面的值进行轮询,比如interval = "10s",那采集时间将是:00, :10, :20, 等
round_interval = true
#每次发送到output的度量大小不能超过metric_batch_size的值, 个数
metric_batch_size = 1000
#telegraf会为每一个output去缓存一份度量值,metric_buffer_limit为缓存的限制,并且刷新buffer以确定成功写入。如果达到这个限制了,老的数据会被第一时间丢弃
#当然了,增加这个值能够容忍更多的数据连接,但是这也将会增加telegraf潜在的内存占用。这个值可以大于metric_batch_size但是必须小于它的两倍
metric_buffer_limit = 10000
#通过随机度量来对采集时间进行抖动。每个插件在采集数据之前将会有一个随机时间的休眠
#这个设置是为了防止多个采集源数据同一时间都在队列
collection_jitter = "0s"
#默认所有数据flush到outputs的时间(在数据被flush到output之前,最大能到flush_interval + flush_jitter)。不能低于interval
flush_interval = "10s"
# 通过随机数来对flush间隔进行抖动。这个主要是为了避免当运行一个大的telegraf实例的时候有比较大的写入。(jitter=5s,flush_interval=10s意味着每10-15s会发生一次flush操作)
flush_jitter = "0s"
#默认这个值被设置相同的时间戳通过采集间隔排序。最大值为1s。这个指标一般不会用在service input(比如logparser和statsd)。单位(ns,us,ms,s)
precision = ""
#以debug模式运行
debug = false
#以安静模式运行
quiet = false
#这个将会覆盖默认的hostname,如果为空的话,将会采用os.Hostname()
hostname = ""
#如果设置为true,就不允许在telegraf agent里面设置"host"标签了
omit_hostname = false
###############################################################################
# INPUT PLUGINS #
###############################################################################
# inputs插件全局参数:
#每一个input都可以配置的全局配置项
#name_override:覆盖默认的度量值名字(默认是input的名字)
#name_prefix:指定一个前缀并附加到度量值的名字(measuerments name)
#name_suffix:指定后缀
#interval:多久采集一次数据,默认可用使用全局配置中的参数
# Read metrics about cpu usage
[[inputs.cpu]]
## Whether to report per-cpu stats or not
percpu = true
## Whether to report total system cpu stats or not
totalcpu = true
## If true, collect raw CPU time metrics.
collect_cpu_time = false
## If true, compute and report the sum of all non-idle CPU states.
report_active = false
# Read metrics about disk usage by mount point
[[inputs.disk]]
## By default stats will be gathered for all mount points.
## Set mount_points will restrict the stats to only the specified mount points.
# mount_points = ["/"]
## Ignore mount points by filesystem type.
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"]
# Read metrics about disk IO by device
[[inputs.diskio]]
## By default, telegraf will gather stats for all devices including
## disk partitions.
## Setting devices will restrict the stats to the specified devices.
# devices = ["sda", "sdb", "vd*"]
## Uncomment the following line if you need disk serial numbers.
# skip_serial_number = false
#
## On systems which support it, device metadata can be added in the form of
## tags.
## Currently only Linux is supported via udev properties. You can view
## available properties for a device by running:
## 'udevadm info -q property -n /dev/sda'
## Note: Most, but not all, udev properties can be accessed this way. Properties
## that are currently inaccessible include DEVTYPE, DEVNAME, and DEVPATH.
# device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"]
#
## Using the same metadata source as device_tags, you can also customize the
## name of the device via templates.
## The 'name_templates' parameter is a list of templates to try and apply to
## the device. The template may contain variables in the form of '$PROPERTY' or
## '${PROPERTY}'. The first template which does not contain any variables not
## present for the device is used as the device name tag.
## The typical use case is for LVM volumes, to get the VG/LV name instead of
## the near-meaningless DM-0 name.
# name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"]
# Get kernel statistics from /proc/stat
[[inputs.kernel]]
# no configuration
# Read metrics about memory usage
[[inputs.mem]]
# no configuration
# Get the number of processes and group them by status
[[inputs.processes]]
# no configuration
# Read metrics about swap memory usage
[[inputs.swap]]
# no configuration
# Read metrics about system load & uptime
[[inputs.system]]
# no configuration
# # Statsd UDP/TCP Server
[[inputs.statsd]]
# ## Protocol, must be "tcp", "udp", "udp4" or "udp6" (default=udp)
protocol = "udp"
#
# ## MaxTCPConnection - applicable when protocol is set to tcp (default=250)
# max_tcp_connections = 250
#
# ## Enable TCP keep alive probes (default=false)
# tcp_keep_alive = false
#
# ## Specifies the keep-alive period for an active network connection.
# ## Only applies to TCP sockets and will be ignored if tcp_keep_alive is false.
# ## Defaults to the OS configuration.
# # tcp_keep_alive_period = "2h"
#
# ## Address and port to host UDP listener on
service_address = ":8125"
#
# ## The following configuration options control when telegraf clears it's cache
# ## of previous values. If set to false, then telegraf will only clear it's
# ## cache when the daemon is restarted.
# ## Reset gauges every interval (default=true)
# delete_gauges = true
# ## Reset counters every interval (default=true)
# delete_counters = true
# ## Reset sets every interval (default=true)
# delete_sets = true
# ## Reset timings & histograms every interval (default=true)
# delete_timings = true
#
# ## Percentiles to calculate for timing & histogram stats
percentiles = [90, 99]
#
# ## separator to use between elements of a statsd metric
metric_separator = "."
###############################################################################
# OUTPUT PLUGINS #
###############################################################################
#输出插件,我们使用的是influxdb,得先进行安装配置
[[outputs.influxdb]]
# influxdb 的地址
urls = ["http://influxdb:8086", ] # required
#默认需要连接的telegraf库,没有则自动创建
database = "bytepower" # required
precision = "s"
#修改保留策略
retention_policy = ""
#持续写入,仅支持集群模式, can be: "any", "one", "quorum", "all"
write_consistency = "any"
#作为influxdb客户端,设置写超时时间,如果为空默认为5s超时,0s表示不设置超时时间(不建议)
timeout = "5s"
#设置bytepower的库的用户名和密码, 需要在 influxdb 进行配置
username = "admin"
password = "admin"
###############################################################################
# PROCESSOR PLUGINS #
###############################################################################
###############################################################################
# AGGREGATOR PLUGINS #
###############################################################################