telegraf学习

1.启动-需指定配置文件

/usr/bin/telegraf --config /etc/telegraf/cpu.conf


 

2.配置文件

(1)agent

[agent]
logfile = "/var/log/telegraf/telegraf.log"
logfile_rotation_max_size = "10MB"
logfile_rotation_max_archives = 5
log_with_timezone = "local"
round_interval = true
interval = "1m"
collection_jitter = "15s"
flush_interval = "15s"
flush_jitter = "5s"

  • collection_jitter: Collection jitter is used to jitter the collection by a random interval. Each plugin will sleep for a random time within jitter before collecting. This can be used to avoid many plugins querying things like sysfs at the same time, which can have a measurable effect on the system.

  • flush_interval: Default flushing interval for all outputs. Maximum flush_interval will be flush_interval + flush_jitter.

  • flush_jitter: Default flush jitter for all outputs. This jitters the flush interval by a random amount. This is primarily to avoid large write spikes for users running a large number of telegraf instances. ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s.

(2)global_tags 自定义的全局tags

[global_tags]

idc = "xiongan02"
alert_tag = "11.0.96.125"
service_tree="untube_virtual_network_element_elb"


 

 (3)outputs.http 可直接推送到prometheusremote

[[outputs.http]]
#url = "http://13.0.127.248:9091/metrics/job/lb_telegraf_job"
url = "http://11.0.103.248:9090/api/v1/write"

data_format="prometheusremotewrite"

  data_format = "prometheus"


 

(4)[[processors.rename]] 可修改指标名称以及tag

[[processors.replace]]
[[processors.replace.rename]]
measurement = "ping"
measurement_dest = "probe"
field = "result_code"
field_dest = "success"

  [[processors.rename.replace]]
    measurement = "network_interface_throughput"
    dest = "throughput"

  [[processors.rename.replace]]
    tag = "hostname"
    dest = "host"

  [[processors.rename.replace]]
    field = "lower"
    dest = "min"

  [[processors.rename.replace]]
    field = "upper"
    dest = "max"

(5)

[[inputs.mem]]

 fieldpass= ["",]

 

[[inputs.procstat]]
pattern="named"
pid_tag = true

 

[[inputs.procstat]]
pattern="nginx"
pid_tag = true

 

posted @ 2023-02-02 15:33  spx88  阅读(321)  评论(0编辑  收藏  举报