telegraf input 点滴
1 telegraf [inputs.net]采集数据时interface介绍:
input net 会默认采集服务器所有的ip addres 如:lo, eth*
interfaces = ["eth*", "enp0s[0-1]", "lo"....] ,如 rancher服务器 的net 会采集 eth0 ,loopback,docker0,各pod的地址
influxdb中 带宽查看(1分钟采集一次) 下行Mb: bytes_recv/1024/1024/(60/8) as "download Mb/s" 上行:bytes_sent/1024/1024/7.5 as "upload Mb/s" 其中bytes_recv,bytes_sent为累计值(后一分钟减前一分钟)
influxbd查看bytes_recv ,bytes_sent SELECT bytes_recv,bytes_sent FROM net WHERE time > now() - 10m and ip=ip and interface='eth0' limit 5, 不指定interface时默认为all
gitlab input net:
# Gather metrics about network interfaces
[[inputs.net]]
## By default, telegraf gathers stats from any up interface (excluding loopback)
## Setting interfaces will tell it to gather these explicit interfaces,
## regardless of status. When specifying an interface, glob-style
## patterns are also supported.
##
# interfaces = ["eth*", "enp0s[0-1]", "lo"]
##
## On linux systems telegraf also collects protocol stats.
## Setting ignore_protocol_stats to true will skip reporting of protocol metrics.
##
# ignore_protocol_stats = false
##
2 telegraf [inputs.exec]采集数据
[[inputs.exec]]
commands=['/bin/bash /etc/telegraf/telegraf.d/mysqlalive.sh',]
timeout='10s'
name_suffix='_collectmysqlalive'
data_format='influx'
#脚本 mysqlalive.sh #/bin/bash alive=`mysqladmin -utelegraf -ptelegraf ping |grep alive |wc -l` alivecode="mysql=ping a=$alive" echo "mysqlalive,$alivecode"
shell 脚本必须以固定格式输出
第二与第三列之间必须为空格
3 telegraf [inputs.mysql]采集数据
mysql 的账号必须有SUPER, REPLICATION CLIENT 权限,如下,telegraf 账号 有SUPER, REPLICATION 权限
[[inputs.mysql]]
servers=['telegraf:telegraf@tcp(127.0.0.1:3306)/']
metric_version=2
gather_slave_status=true
4 telegraf 常见异常
|
预警发生了什么 |
预警级别 |
发给谁 |
传递哪些关键信息 |
接收人需要做什么 |
|
字段类型错误(field type conflict) |
低 |
Jeff |
|
|
|
应用账号权限不足问题(Access denied) |
低 |
Jeff |
|
|
|
应用账号密码错误(ERR invalid password) |
低 |
Jeff |
|
|
|
连接拒绝(connection refused) |
低 |
Jeff |
|
|
由于mysql某些参数开启,和关闭的值不一样,如 slave_skip_errors 开启状态 值为 float类型,关闭状态为string类型,并且 不同mysql 的配置参数可能不一致,这样会导致telegraf字段类型错误
5 telegraf --debug
Telegraf --debug 或telegraf --status 如果参数全部正确,日志不报错,

浙公网安备 33010602011771号