This commit is contained in:
zhangzhihan
2020-06-09 13:10:38 +08:00
parent 792ce3da1a
commit 829dd78560
27 changed files with 198 additions and 41 deletions

View File

@@ -0,0 +1,16 @@
[Unit]
Description=Statistic information
Documentation=https://github.com/influxdata/telegraf
After=network.target
[Service]
EnvironmentFile=-/etc/default/telegraf
User=telegraf
ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf_statistic.conf -config-directory /etc/telegraf/telegraf_statistic.d $TELEGRAF_OPTS
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartForceExitStatus=SIGPIPE
KillMode=control-group
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,28 @@
- name: "copy telegraf.rpm to destination server"
copy:
src: "{{ role_path }}/files/telegraf-1.13.0-1.x86_64.rpm"
dest: /tmp
- name: "install telegraf"
yum:
name:
- /tmp/telegraf-1.13.0-1.x86_64.rpm
state: present
- name: "Templates telegraf.conf"
template:
src: "{{role_path}}/templates/telegraf_statistic.conf.j2"
dest: /etc/telegraf/telegraf_statistic.conf
tags: template
- name: "copy telegraf_statistic.service to destination server"
copy:
src: "{{ role_path }}/files/telegraf_statistic.service"
dest: /usr/lib/systemd/system
chmod: 0755
- name: "Start telegraf"
systemd:
name: telegraf_statistic.service
state: started
enabled: yes

View File

@@ -0,0 +1,29 @@
[global_tags]
[agent]
interval = "30s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
debug = false
quiet = false
logfile = ""
hostname = ""
omit_hostname = false
[[outputs.file]]
files = ["stdout", "/tmp/metrics.out"]
data_format = "json"
[[outputs.kafka]]
brokers = ["{{ log_kafkabrokers.address }}"]
topic = "TRAFFIC-METRICS-LOG"
data_format = "json"
[[outputs.prometheus_client]]
listen = ":9273"
path = "/metrics"
[[inputs.tcp_listener]]
[[inputs.udp_listener]]
ServiceAddress= ":8100"
data_format = "influx"