TICK之CentOS7.6安装Telegraf

Telegraf是TICK堆栈中的度量收集代理。

在安装之前先安装InfluxDB和Chronograf 。

1.下载Telegraf镜像

docker pull telegraf

2.创建数据目录

/root/runenv/opt/docker/telegraf

/root/runenv/opt/docker/telegraf/run

3.导出默认配置文件

docker run --rm telegraf telegraf config > telegraf.conf

4.修改配置文件

主要修改 urls、database、username、password、timeout等配置项

[[outputs.influxdb]]
  ## The full HTTP or UDP URL for your InfluxDB instance.
  ##
  ## Multiple URLs can be specified for a single cluster, only ONE of the
  ## urls will be written to each interval.
  # urls = ["unix:///var/run/influxdb.sock"]
  # urls = ["udp://127.0.0.1:8089"]
  # urls = ["http://127.0.0.1:8086"]
  urls = ["http://ip:8086"]

  ## The target database for metrics; will be created as needed.
  ## For UDP url endpoint database needs to be configured on server side.
  database = "telegraf"

  ## The value of this tag will be used to determine the database.  If this
  ## tag is not set the 'database' option is used as the default.
  # database_tag = ""

  ## If true, no CREATE DATABASE queries will be sent.  Set to true when using
  ## Telegraf with a user without permissions to create databases or when the
  ## database already exists.
  # skip_database_creation = false

  ## Name of existing retention policy to write to.  Empty string writes to
  ## the default retention policy.  Only takes effect when using HTTP.
  #retention_policy = "1h"

  ## Write consistency (clusters only), can be: "any", "one", "quorum", "all".
  ## Only takes effect when using HTTP.
  # write_consistency = "any"

  ## Timeout for HTTP messages.
  timeout = "5s"

  ## HTTP Basic Auth
  username = "用户"
  password = "密码"

  ## HTTP User-Agent
  # user_agent = "telegraf"

  ## UDP payload size is the maximum packet size to send.
  # udp_payload = "512B"

  ## Optional TLS Config for use on HTTP connections.
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

  ## HTTP Proxy override, if unset values the standard proxy environment
  ## variables are consulted to determine which proxy, if any, should be used.
  # http_proxy = "http://corporate.proxy:3128"

  ## Additional HTTP headers
  # http_headers = {"X-Special-Header" = "Special-Value"}

  ## HTTP Content-Encoding for write request body, can be set to "gzip" to
  ## compress body or "identity" to apply no encoding.
  # content_encoding = "identity"

  ## When true, Telegraf will output unsigned integers as unsigned values,
  ## i.e.: "42u".  You will need a version of InfluxDB supporting unsigned
  ## integer values.  Enabling this option will result in field type errors if
  ## existing data has been written.
  # influx_uint_support = false

5.配置数据库

在InfluxDB中创建数据库同配置文件中的 database 参数

创建用户同配置文件中的 username 和 password 参数

6.启动服务

docker run -d --name=telegraf -v /root/runenv/opt/docker/telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro -v /root/runenv/opt/docker/telegraf/run:/var/run telegraf


7.配置Chronograf

Telegraf Database Name 填写上面配置文件中配置的 database

Username 和 Password  填写上面配置文件中配置的 username 和 password

Kapacitor 没有配置,这里选 Skip

8.配置 Dashboard 的查询

选择刚才设置的 Influxdb 连接

 选择 DB.RetentionPolicy,这里选testdb.autogen,选择 Measurements 及 Tags 作为 From 和 Where,选择 Fields 作为 Select,生成查询条件后可手动进行修改,点击 Group By XXX 将该条件加到 GROUP BY 中。

 

可以输入图的名称或其他一些设置后,点击右上角的对勾按钮进行保存

 9.在 Dashboard 中查看,可以修改此 Dashboard 的名称。

至此设置完成,更多功能请大家自己尝试。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值