telegraf安装部署详解


                                                        telegraf 安装部署

简介:

Telegraf 是一个用 Go 编写的代理程序,可收集系统和服务的统计数据,并写入到 InfluxDB 数据库。

Telegraf 具有内存占用小的特点,通过插件系统开发人员可轻松添加支持其他服务的扩展。


官网参考地址 

https://docs.influxdata.com/telegraf/v0.11/

软件下载地址:

https://influxdata.com/downloads/



1:安装部署 


1、下载

wget http://get.influxdb.org/telegraf/telegraf-0.11.1-1.x86_64.rpm


2、安装

yum localinstall telegraf-0.11.1-1.x86_64.rpm -y


3、启动服务、添加开机启动

systemctl start  telegraf.service

service telegraf status

systemctl enable  telegraf.service 


4、查看版本

telegraf --version

Telegraf - Version 0.11.1


配置文件位置(默认配置):/etc/telegraf/telegraf.conf


修改telegraf配置文件添加监控项

vim /etc/telegraf/telegraf.conf 


#修改监控数据输出位置,本次测试环境本地安装有influxdb, 可以保持默认:urls = ["http://localhost:8086"]

 58 `outputs`.`influxdb`

 59   ## The full HTTP or UDP endpoint URL for your InfluxDB instance.

 60   ## Multiple urls can be specified as part of the same cluster,

 61   ## this means that only ONE of the urls will be written to each interval.

 62   # urls = ["udp://localhost:8089"] # UDP endpoint example

 63   urls = ["http://172.16.7.12:8086"] # required

 64   ## The target database for metrics (telegraf will create it if not exists).


2:添加监控项:


1、添加docker 监控项

参考地址:

https://github.com/influxdata/telegraf

`inputs`.`docker`

  #Docker Endpoint

  #To use TCP, set endpoint = "tcp://[ip]:[port]"

  #To use environment variables (ie, docker-machine), set endpoint = "ENV"

  endpoint = "unix:///var/run/docker.sock"

  #Only collect metrics for these containers, collect all if empty

  #container_names = []


2、zookeeper 监控添加

`inputs`.`zookeeper`

 servers = ["172.16.7.12:2181"]


3、mesos监控项

`inputs`.`mesos`

  # Timeout, in ms.

  timeout = 100

  # A list of Mesos masters, default value is localhost:5050.

  masters = ["localhost:5050"]

  # Metrics groups to be collected, by default, all enabled.

  master_collections = ["resources","master","system","slaves","frameworks","messages","evqueue","registrar"]



以上新加3个监控项,可以通过命令测试配置是否成功。

telegraf  -config /etc/telegraf/telegraf.conf -input-filter mesos -test

telegraf  -config /etc/telegraf/telegraf.conf -input-filter docker -test

telegraf  -config /etc/telegraf/telegraf.conf -input-filter zookeeper  -test


 

3:修改telegraf  服务启动用户,默认用户无法通过sock 获取doker 数据。


[root@ctn-7-11 grafana]# vi /usr/lib/systemd/system/telegraf.service 

[Unit]

Description=The plugin-driven server agent for reporting metrics into InfluxDB

Documentation=https://github.com/influxdata/telegraf

After=network.target


[Service]

EnvironmentFile=-/etc/default/telegraf

#User=telegraf

#本次测试环境直接改为root

User=root

ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d 。。。。。。。



4:重启服务,使配置生效

systemctl daemon-reload

systemctl restart telegraf

ps -ef|grep telegraf


1、验证


root      7244  4292  0 17:44 pts/0    00:00:00 grep --color=auto telegraf

telegraf (默认启动用户)31793     1  0 15:48 ?        00:00:37 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d



#启动脚本修改后

root      3283     1  2 17:24 ?        00:00:00 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d

root      3402  8804  0 17:24 pts/0    00:00:00 grep --color=auto telegraf



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值