Join us for a virtual meetup on Zoom at 8 PM, July 31 (PDT) about using One Time Series Database for Both Metrics and Logs 👉🏻 Register Now

Skip to content
On this page
Tutorial
July 4, 2024

Connect to more than 200 event sources - Use GreptimeDB as a Telegraf Output Destination

GreptimeDB accepts data ingested via InfluxDB line protocol. It enables users to connect more than 200 event sources supported by Telegraf, while using GreptimeDB as an instance of the "influxdb" output destination. This blog provides a tutorial on how to set up this integration and query the ingested data.

Telegraf is an open source server agent that help users collect metrics from stacks, sensors, and systems. It supports more than 200 event sources, ranging from IoT sensors, DevOps tools and frameworks, system telemetry and more. Telegraf also implements several processor and aggregator plugins, which preprocess and preaggregate the collected data before ingesting into the output destination.

As shown in the "Ingestion by InfluxDB line protocol, Analysis with SQL and PromQL" demo, GreptimeDB can be used as a server acceptings InfluxDB line protocol write calls. This allows users to use GreptimeDB as an instance of the "influxdb" output destination of Telegraf, enabling them to connect to all event sources, as well as benefit from its processors and aggregators.

GreptimeDB supports both InfluxDB v1 and v2 write APIs. To simplify the configure, since GreptimeDB doesn't use the "organization" concept that is required in V2, this tutorial uses the InfluxDB v1.x output plugin.

Set up Greptime Service

Let's first set up the output destination.

The fastest way to get a GreptimeDB cluster is to start a Hobby plan service on GreptimeCloud. Note that the Hobby plan is completely free with no credit card info needed.

Follow the instructions from GreptimeCloud to create a new GreptimeDB service, and click the "Connection Information" button to find the connection information. Then, export the necessary environment variables:

shell
export GREPTIME_HOST="<host>"
export GREPTIME_DATABASE="<dbname>"
export GREPTIME_USERNAME="<username>"
export GREPTIME_PASSWORD="<password>"

Connection Information

Configure and start a Telegraf instance

Now that the GreptimeDB service is ready, the next step is to start a Telegraf instance to collect and transform events.

If you don't have Telegraf installed, head to its Install page for a guidance. For example, you can install Telegraf with Homebrew by:

shell
brew install telegraf

Then, you can generate a config file by:

shell
telegraf --sample-config > telegraf.conf

You should modify the [[outputs.influxdb]] section to configure GreptimeDB's connection info:

toml
[[outputs.influxdb]]
urls = ["https://${GREPTIME_HOST}/v1/influxdb/"]
database = "${GREPTIME_DATABASE}"
username = "${GREPTIME_USERNAME}"
password = "${GREPTIME_PASSWORD}"
skip_database_creation = true

Finally, you can choose any input plugin to start collecting statistics.

For example, you can collect system metrics with the following input plugins:

toml
[[inputs.cpu]]
collect_cpu_time = false
core_tags = false
percpu = true
report_active = false
totalcpu = true

[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]

[[inputs.diskio]]

[[inputs.mem]]

[[inputs.processes]]

[[inputs.system]]

Add some processors and aggregators:

toml
[[processors.printer]]

[[aggregators.minmax]]
period = "30s"
drop_original = false

Now, let's start the telegraf instance with this config:

shell
telegraf --config telegraf.conf

Query events collected

You can make sample queries from the Web Dashboard:

Web Dashboard Entrypoint
Head to the Web Dashboard
SQL Editor
Query events with SQL

Instead, you can also build charts from the statstics for visualization:

Workbench Panels
Visualize Metrics into Charts

About Greptime

We help industries that generate large amounts of time-series data, such as Connected Vehicles (CV), IoT, and Observability, to efficiently uncover the hidden value of data in real-time.

Visit the latest version from any device to get started and get the most out of your data.

  • GreptimeDB, written in Rust, is a distributed, open-source, time-series database designed for scalability, efficiency, and powerful analytics.
  • Edge-Cloud Integrated TSDB is designed for the unique demands of edge storage and compute in IoT. It tackles the exponential growth of edge data by integrating a multimodal edge-side database with cloud-based GreptimeDB Enterprise. This combination reduces traffic, computing, and storage costs while enhancing data timeliness and business insights.
  • GreptimeCloud is a fully-managed cloud database-as-a-service (DBaaS) solution built on GreptimeDB. It efficiently supports applications in fields such as observability, IoT, and finance.

Star us on GitHub or join GreptimeDB Community on Slack to get connected. Also, you can go to our contribution page to find some interesting issues to start with.

Integration
Telegraf

Join our community

Get the latest updates and discuss with other users.