Telegraf

https://github.com/influxdata/telegraf

The plugin-driven server agent for collecting & reporting metrics.


Configuartion

agent configuration:

1
2
3
4
5
6
interval    所有inputs的默认运行间隔
round_interval
collection_jitter
precision    ns/us/ms/s
flush_interval
flush_jitter

input configuration:

1
2
3
4
5
interval
name_override # 默认measurements是插件名,修改默认measurements.
name_prefix
name_suffix
tags

Go API

https://godoc.org/github.com/influxdata/telegraf#Input

测试插件:

1
2
# 需要配置文件
$ telegraf --input-filter <plugin-name> --test

Build

安装依赖:

1
2
3
sudo apt-get install ruby-dev
sudo gem install fpm
sudo apt-get install rpm

编译telegraf:

1
make telegraf

生成配置文件:

1
./telegraf config > ./etc/telegraf.conf

构建deb:

1
make package

Development

修改默认enable的plugin:

1
2
3
4
# plugin中相应的sampleConfig中的字段不要用#注释.
internal/config/config.go -> 可以修改默认enable的plugin.
inputDefaults
outputDefaults

调试:

1
./telegraf --config ./etc/telegraf.conf --input-filter process --test

添加debugxinxi

1
2
3
import "log"
log.Printf("D! key: %v", value)
# "D!" 开头的信息当debug=true才会打印.