Skip to content

Telegraf_

LinShunKang edited this page Feb 2, 2022 · 13 revisions

MyPerf4J 2.0 及其之前本身不访问 InfluxDB,而是通过把统计数据写入日志文件中,通过 Telegraf 把统计数据导入 InfluxDB 中。

步骤如下:

  • 安装 Telegraf

  • 配置 /usr/local/etc/telegraf.conf

    # Global tags can be specified here in key="value" format.
    [global_tags]
      dc = ""
    
    # Configuration for telegraf agent
    [agent]
      ## Default data collection interval for all inputs
      interval = "1s"
      ## Rounds collection interval to 'interval'
      ## ie, if interval="10s" then always collect on :00, :10, :20, etc.
      round_interval = true
      metric_batch_size = 1000
      metric_buffer_limit = 10000
      collection_jitter = "0s"
      ## Default flushing interval for all outputs. You shouldn't set this below
      ## interval. Maximum flush_interval will be flush_interval + flush_jitter
      flush_interval = "1s"
      flush_jitter = "0s"
      precision = "ms"
      debug = false
      quiet = false
      logfile = "/tmp/telegraf.log"
      ## Override default hostname, if empty use os.Hostname()
      hostname = ""
      ## If set to true, do no set the "host" tag in the telegraf agent.
      omit_hostname = false
    
    [[outputs.influxdb]]
      urls = ["http://127.0.0.1:8086"]
      database = "MyPerf4J_Test"
      retention_policy = ""
      write_consistency = "any"
      timeout = "5s"
    
    [[inputs.tail]]
      files = ["/data/logs/MyPerf4J/metrics.log"]
      from_beginning = false
      pipe = false
      ## Method used to watch for file updates.  Can be either "inotify" or "poll".
      watch_method = "inotify"
      data_format = "influx"
    
  • 启动 Telegraf

  • 下一步