Using Telegraf with CrateDB

Telegraf is a plugin-driven server agent for collecting, processing, aggregating, and writing metrics.

This document will show you how to connect Telegraf to CrateDB, so that you can take advantage of the many things that CrateDB has to offer.

Table of Contents


You will need to install Telegraf.

Once Telegraf is installed, continue to the next section.


Create the default config:

./telegraf config > telegraf.conf

Now, configure CrateDB instead of InfluxDB (which is the default output destination).

Do this by finding and removing the InfluxDB config from the telegraf.conf file, and then adding your CrateDB config.

Your CrateDB config should look something like this:


# A lib/pq connection string.
# See
url = "postgres://crate@localhost/doc?sslmode=disable"
# Timeout for all CrateDB queries.
timeout = "5s"
# Name of the table to store metrics in.
table = "metrics"
# If true, and the metrics table does not exist, create it automatically.
table_create = true


Once Telegraf has been configured, you can start it, like so:

./telegraf --config telegraf.conf

When Telegraf starts, the metrics table will be created in the default doc schema.

If you want to use a different schema, you can specify it using the standard syntax, i.e. by specifying my_schema.metrics for table.

A few seconds later, you will see Telegraf metrics being written to this table.