- Guide for Set Up of Telegraf for Monitoring SQL Server xPlat
- Guide for Set Up of Telegraf for Monitoring Windows
- Setting up Telegraf to Startup on Windows
- Guide for Setting up Telegraf to Monitor InfluxDB
- Telegraf Setup FAQ for Troubleshooting
Problem
If you been reading this series you are used to looking at Windows and SQL Server but who knows what InfluxDB is and what to look at there especially if installed it on Linux. Lucky for us there is a dashboard to use to watch InfluxDB as well so we can watch the performance of that machine as well.
Solution
First, we need to create a database to store the database for the Telegraf InfluxDB information by entering into the program by typing:
influx
Then we create a database and set your retention policy for 365 days or adjust to your needs:
CREATE DATABASE telegraf_internal CREATE RETENTION POLICY internal_1yr ON telegraf_internal DURATION 365d REPLICATION 1 DEFAULT
And then you can run this to show databases:
SHOW DATABASES
Then just type Exit to leave influx.
exit
That’s it InfluxDB is installed and ready to go your database is ready to go.
Install Telegraf on InfluxDB on Linux
Now to install Telegraf on the InfluxDB server. So we first need to download install the package.
wget https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly.x86_64.rpm sudo yum localinstall telegraf-nightly.x86_64.rpm
We need to generate a special config file for the Linux machine to capture the CPU and disk metrics. This config file will be in your /etc/telegraf folder.
cd /bin/telegraf ./telegraf --config /etc/telgraf/telegraf.conf --input-filter cpu:mem:influxdb --output-filter influxdb
After you run this you will need to open it with your favorite editor, mine is vim:
sudo vi /etc/telegraf/telegraf.conf
Once the file the is open you can type the letter i to be able to edit the file. Then type /influxdb to find the outputs.influxdb section of the file and edit the same sections we edited for Windows. Type /inputs.outfluxdb to jump down and edit the InFluxdb section. After you have finished editing the file in vim you can type Esc then :wq! and the hit Enter for it save the config file. Below is a sample config file:
[[outputs.influxdb]] ## The full HTTP or UDP URL for your InfluxDB instance. ## ## Multiple urls can be specified as part of the same cluster, ## this means that only ONE of the urls will be written to each interval. # urls = ["udp://127.0.0.1:8089"] # UDP endpoint example urls = ["http://localhost:8086"] # required ## The target database for metrics (telegraf will create it if not exists). database = "telegraf_internal" # required ############################################################################### # INPUT PLUGINS # ############################################################################### [[inputs.cpu]] ## Whether to report per-cpu stats or not percpu=true ## Whether to report total system cpu stats or not totalcpu = true ## If true, collect raw CPU time metrics. collect_cpu_time = false ## If true, computer and report the sum of all non-idle CPU states. report-active = false [[inputs.disk]] ## By default, telegraf gather stats for all mountpoints. ## Setting mountpoints will restrict the stats to the specified mountpoints. ## mount_points =disk ["/"] ## Ignore some mountpoints by filesream type. For exmpla (dev)tmpfs (usually ## present on /run, //var/run, /dev/shm or /dev). ignore_fs = ["tmpfs", "devtmpfs", "devfs"] [[inputs.influxdb]] urls = ["http://localhost:8086/debug/vars"] + timeout = "5s"
Next, you want to start the telegraf service and set it to autostart but before that, we need to open the port to InfluxDB:
sudo service telegraf start sudo systemctl enable telegraf
Setup the Data Source
In Grafana, set up a new data source. Set your Name to match mine to so you don’t have to change my dashboard unless you are comfortable doing so, select Type InfluxDB, type in the URL of the InfluxDB, and finally specify the database. Then Click Save and Test.
Finally
We are ready to import the Dashboard. Download all dashboards from GitHub. Import the dashboard and you should get a dashboard that looks like the following: