Telegraf 介绍

发布时间: 更新时间: 总字数:212 阅读时间:1m 作者: IP上海 分享 网址

Telegraf 介绍

安装

wget https://dl.influxdata.com/telegraf/releases/telegraf-1.18.3-1.x86_64.rpm
sudo yum localinstall telegraf-1.18.3-1.x86_64.rpm

配置

  • 配置 /etc/telegraf/telegraf.conf参考
[agent]
  ## Default data collection interval for all inputs
  interval = "10m"

[[outputs.influxdb]]  # 配置数据库
  urls = ["http://127.0.0.1:8086"]
  database = "telegraf"
  username = "telegraf"
  password = "metricsmetricsmetricsmetrics"
  • 通过 Telegraf 的 inputs.exec 插件执行,配置如下:
# Read metrics from one or more commands that can output to stdout
[[inputs.exec]]
  ## Commands array
  commands = [
    "/tmp/test.sh",
  ]

  ## Timeout for each command to complete.
  timeout = "5s"

  ## measurement name suffix (for separating different commands)
  name_suffix = "_mycollector"

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  data_format = "influx"
  • 其中,采集脚本 /tmp/test.sh,也可以使用 python 等封装为 InfluxDB Line Protocol 格式
#!/bin/sh
echo 'example,tag1=a,tag2=b i=42i,j=43i,k=44i'
# echo 'example,tag1=a,tag2=b i=42i,j=43i,k=44i to_timestap("2021-05-30")'
  • 启动 telegraf
systemctl start telegraf.service
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数