The following demos getting started with Telegraf quickly using Docker to monitor the local system.
This example will use Docker to launch a Telegraf container:
docker pull telegraf
Refer to the Install Guide for the full list of ways to install Telegraf.
Telegraf requires a configuration to start up. A configuration requires at least one input to collect data from and one output to send data to. The configuration file is a TOML file.
$ cat config.toml
[[inputs.cpu]]
[[inputs.mem]]
[[outputs.file]]
The above enables two inputs, CPU and Memory, and one output file. The inputs will collect usage information about the CPU and Memory, while the file output is used to print the metrics to STDOUT.
Note that defining plugins to use are a TOML array of tables. This means users can define a plugin multiple times. This is more useful with other plugins that may need to connect to different endpoints.
With the image downloaded and a config file created, launch the image:
docker run --rm --volume $PWD/config.toml:/etc/telegraf/telegraf.conf telegraf
The user will see some initial information print out about which config file was loaded, version information, and what plugins were loaded. After the initial few seconds metrics will start to print out.
To go beyond this quick start, users should consider the following:
- Determine where you want to collect data or metrics from and look at the available input plugins
- Determine where you want to send metrics to and look at the available output plugins
- Look at the install guide for the complete list of methods to deploy and install Telegraf
- If parsing arbitrary data or sending metrics or logs to Telegraf, read through the parsing data guide.