Use Telegraf as the collector for Nightingale. Telegraf is an agent from InfluxData for collecting, processing, aggregating and writing metrics. It supports many output plugins; the opentsdb or prometheusremotewrite plugin can be used to send metrics to Nightingale.
Introduction
Telegraf is an agent from InfluxData for collecting, processing, aggregating and writing metrics.
Telegraf supports many output plugins; we can use the opentsdb or prometheusremotewrite plugin to send metrics to Nightingale. The example below uses opentsdb.
Installation
#!/bin/sh
version=1.20.4
tarball=telegraf-${version}_linux_amd64.tar.gz
wget https://dl.influxdata.com/telegraf/releases/$tarball
tar xzvf $tarball
mkdir -p /opt/telegraf
cp -far telegraf-${version}/usr/bin/telegraf /opt/telegraf
cat <<EOF > /opt/telegraf/telegraf.conf
[global_tags]
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
hostname = ""
omit_hostname = false
[[outputs.opentsdb]]
host = "http://127.0.0.1"
port = 17000
http_batch_size = 50
http_path = "/opentsdb/put"
debug = false
separator = "_"
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = true
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.system]]
fielddrop = ["uptime_format"]
[[inputs.net]]
ignore_protocol_stats = true
EOF
cat <<EOF > /etc/systemd/system/telegraf.service
[Unit]
Description="telegraf"
After=network.target
[Service]
Type=simple
ExecStart=/opt/telegraf/telegraf --config telegraf.conf
WorkingDirectory=/opt/telegraf
SuccessExitStatus=0
LimitNOFILE=65535
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=telegraf
KillMode=process
KillSignal=SIGQUIT
TimeoutStopSec=5
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable telegraf
systemctl restart telegraf
systemctl status telegraf
Common Questions
Q1: How does Telegraf send data to n9e?
A: Use Telegraf’s [outputs.http] plugin, with the URL pointing to n9e-pushgw’s /openfalcon/push or /prometheus/v1/write endpoint. See above for detailed configuration.
Q2: Telegraf is installed but n9e doesn’t receive any data?
A:
- Check whether
output.httpis enabled in the Telegraf configuration; - Make sure the URL path is correct (don’t omit
/api/v1/...); - Choose the right data format (Prometheus / OpenFalcon / OpenTSDB);
- Network: on the Telegraf host, run
curl <n9e-pushgw>:17000/-/healthyto test.
Q3: Can I keep Telegraf’s configuration when migrating to Categraf?
A: Many of Categraf’s plugin names and configuration items are aligned with Telegraf’s, so migration costs are low. Some legacy plugins may need to be renamed — see the migration table in the Categraf documentation.