Skip to main content
Telegraf is a server-based agent that collects and sends metrics and events from databases, systems, and IoT sensors. Telegraf is an open-source, plugin-driven tool for the collection and output of data. To view metrics gathered by Telegraf and stored in a in a :

Prerequisites

Best practice is to use an Ubuntu EC2 instance hosted in the same region as your as a migration machine. That is, the machine you run the commands on to move your data from your source database to your target . Before you migrate your data:
  • Create a target . Each has a single database that supports the most popular extensions. s do not support tablespaces, and there is no superuser associated with a . Best practice is to create a with at least 8 CPUs for a smoother experience. A higher-spec instance can significantly reduce the overall migration window.
  • To ensure that maintenance does not run during the process, adjust the maintenance window.
To create a Telegraf configuration that exports data to a in your :
  1. Set up your connection string This variable holds the connection information for the target . In the terminal on the source machine, set the following:
    See where to find your connection details.
  2. Generate a Telegraf configuration file In Terminal, run the following:
    telegraf.conf configures a CPU input plugin that samples various metrics about CPU usage, and the output plugin. telegraf.conf also includes all available input, output, processor, and aggregator plugins. These are commented out by default.
  3. Test the configuration
    You see an output similar to the following:
  4. Configure the output plugin
    1. In telegraf.conf, in the [[outputs.postgresql]] section, set connection to the value of $TARGET.
    2. Use s when Telegraf creates a new table: In the section that begins with the comment ## Templated statements to execute when creating a new table, add the following template:

View the metrics collected by Telegraf

This section shows you how to generate system metrics using Telegraf, then connect to your and query the metrics .
  1. Collect system metrics using Telegraf Run the following command for 30 seconds:
    Telegraf uses loaded inputs cpu and outputs postgresql along with global tags, the intervals when the agent collects data from the inputs, and flushes to the outputs.
  2. View the metrics
    1. Connect to your :
    2. View the metrics collected in the cpu table in tsdb:
      You see something like:
      To view the average usage per CPU core, use SELECT cpu, avg(usage_user) FROM cpu GROUP BY cpu;.
For more information about the options that you can configure in Telegraf, see the output plugin.