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 脚本必须以固定格式输出

 第二与第三列之间必须为空格

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

  1. 服务器ip
  2. 服务器负责人
  3. 监控的应用,如redis
  4. 错误内容
  5. 原因:字段类型不一致导致
  1. 调整input 参数
  2. 保证监控应用版本一致
  3. 处理influxdb中measurement
  4. 查看异常参数状态
  5. 将此指标忽略,如忽略avg_latency:fielddrop = ["avg_latency"]

应用账号权限不足问题(Access denied)

Jeff

  1. 服务器ip
  2. 服务器负责人
  3. 监控的应用,如mysql
  4. 错误内容
  5. 原因:telegraf 连接应用的账号权限不够
  1. 调整此应用账号权限

应用账号密码错误(ERR invalid password)

Jeff

  1. 服务器ip
  2. 服务器负责人
  3. 监控的应用,如redis
  4. 错误内容
  5. 原因:密码错误
  1. 检查密码是否异常

连接拒绝(connection refused)

Jeff

  1. 服务器ip
  2. 服务器负责人
  3. 监控的应用,如nginx
  4. 错误内容
  5. 原因:应用url地址错误
  1. 修改为正确的应用url地址

 

由于mysql某些参数开启,和关闭的值不一样,如 slave_skip_errors  开启状态 值为 float类型,关闭状态为string类型,并且 不同mysql 的配置参数可能不一致,这样会导致telegraf字段类型错误

 

 

5 telegraf --debug

Telegraf --debug  或telegraf --status 如果参数全部正确,日志不报错,

 

posted @ 2020-06-12 15:32  云清拓  阅读(847)  评论(0)    收藏  举报