Telegraf is InfluxData’s open source agent for collecting metrics and writing them in the correct format to InfluxDB. If you want to monitor your servers and infrastructure, the quickest way to gather their metrics and get them into InfluxCloud is via Telegraf.
Telegraf can collect metrics from several inputs and write data to several outputs; here we’ll set up Telegraf to collect system metrics on your local machine and output those data to your InfluxCloud instance or cluster.

To get familiar with Telegraf and its capabilities, let’s install it on your local machine.

1. Download and install Telegraf

On your local machine, download Telegraf by following the steps on the downloads page.

2. Configure Telegraf

On your local machine, create a new configuration file called telegraf.conf:

telegraf -sample-config -input-filter cpu:mem -output-filter influxdb > telegraf.conf

Your new configuration file tells Telegraf to collect information about your system’s CPU usage and memory usage. It also tells Telegraf to send that information to InfluxDB.

You need to make three small edits to telegraf.conf before you can start sending data to your InfluxCloud instance or cluster. In the OUTPUT PLUGINS section of telegraf.conf:

  • Change the urls setting to https:// and your InfluxCloud hostname.
  • Uncomment the username setting by deleting the # and enter the username that you used to create your instance or cluster between the quotes.
  • Uncomment the password setting by deleting the # and enter the password that you used to create your instance or cluster between the quotes.
###############################################################################
#                            OUTPUT PLUGINS                                   #
###############################################################################

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
  ## The full HTTP or UDP endpoint 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://localhost:8089"] # UDP endpoint example
  urls = ["<https://your_InfluxCloud_hostname>:8086"] # required ✨
  ## The target database for metrics (telegraf will create it if not exists).
  database = "telegraf" # required
  ## Retention policy to write to.
  retention_policy = "default"
  ## Precision of writes, valid values are "ns", "us" (or "µs"), "ms", "s", "m", "h".
  ## note: using "s" precision greatly improves InfluxDB compression.
  precision = "s"

  ## Write timeout (for the InfluxDB client), formatted as a string.
  ## If not provided, will default to 5s. 0s means no timeout (not recommended).
  timeout = "5s"
  username = "<your_username>" # ✨
  password = "<your_password>" # ✨

If you’re running OS X on your local machine, you’re free to move on to the next step. If you’re running a version of Linux, copy your new configuration file to /etc/telegraf/telegraf.conf:

sudo cp telegraf.conf /etc/telegraf/telegraf.conf

3. Start Telegraf

Note: If you installed Telegraf from a debian package, Telegraf is already running using the default configuration. You’ll need to restart Telegraf to take into account your new configuration settings.

OS X Homebrew:
telegraf -config telegraf.conf
Linux debian and RPM packages:
sudo service telegraf start
Ubuntu 15+
systemctl start telegraf

4. Exploring the Telegraf data

Now that you’ve started the Telegraf process, Telegraf is collecting system metrics on your local machine and is sending those metrics to a new database (telegraf) on your InfluxCloud instance.

You can explore the data via Chrongraf, which is part of your InfluxCloud subscription.

– or –

If you prefer to use the InfluxCL, you can expore the data from the command line.

You’ve now successfully configured Telegraf to collect data and write data to your InfluxCloud instance or cluster. To learn more about the system metrics Telegraf is sending to your instance or cluster, as well as more information about what you can do with Telegraf see our Telegraf documentation.