Telegraf to M3 to Grafana® Example#

Aiven for M3 + Telegraf set up#

At a high level, here’s how to set up Telegraf to push metrics to Aiven for M3.

  1. Create Aiven for M3 Service

  2. Install and configure Telegraf Agent

  3. Setup Aiven for Grafana® instance for visualization of telegraph metrics

  4. Enjoy the fruits of your labor!

Create Aiven for M3 service#

If you don’t have an existing Aiven account, please follow this link to sign up for a free 30 day trial with $300 of credits:

Within your existing Aiven project, create a new M3 service.

  1. Under Create Service, select M3.

  2. Select a cloud provider

  3. Select a region

Screenshot creating M3 service
  1. Select a service plan type. Startup-8 will be fine for this demo.


Aiven never charges for networking costs. What you see for the price is what you will pay at the end of the month!

  1. Enter a name for the service.

  2. Click the Create Service button.

Screenshot creating M3 service

Navigate to the newly created M3 service via the left-side menu and the service listing, and click the InfluxDB® tab. You will use several values from this page including the Service URI, user, and password when configuring Telegraf in the next section of this blog.

M3 Endpoint

Install Telegraf#

To simplify this example, we will install the Telegraf agent on a MacBook to collect the system metrics. Of course, Telegraf can also be installed on Windows and Linux machines.

Assuming you have Homebrew installed on a MacBook, simply run the following command at the Terminal to install Telegraf (

brew update && brew install telegraf

Configure Telegraf and integrate it with M3#

Use the Telegraf agent to generate a default configuration file for editing:

telegraf config > telegraf.conf

Modify the telegraf.conf configuration file to change the output endpoint to that of our M3 instance.

Change the URL under the outputs.influxdb section to that of your Aiven for M3 service (see above). NOTE: The URL prefix should simply be https:// and remove the username:password from the URI (see snippet below).

Specify the service username/password and set the database name to default (the database that is automatically created when your service is provisioned):

  urls = [""]
  database = "default"
  skip_database_creation = true
  username = "avnadmin"
  password = "my_service_password"

Finally, start Telegraf using the configuration file and begin sending system metrics to M3 by running the command below:

telegraf -config telegraf.conf

Wait 10 seconds or so (the default collection interval) to see if there are any error messages displayed in the terminal:

MacBook-Pro tmp % telegraf -config telegraf.conf
2021-10-08T01:21:15Z I! Starting Telegraf 1.20.1
2021-10-08T01:21:15Z I! Loaded inputs: cpu disk diskio kernel mem processes swap system
2021-10-08T01:21:15Z I! Loaded aggregators:
2021-10-08T01:21:15Z I! Loaded processors:
2021-10-08T01:21:15Z I! Loaded outputs: influxdb
2021-10-08T01:21:15Z I! Tags enabled: host=MacBook-Pro
2021-10-08T01:21:15Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"MacBook-Pro", Flush Interval:10s

Create Aiven for Grafana service#

In the Aiven Console, navigate to the M3 service and click the ‘Manage integrations’. Connect your M3 instance to a new Grafana dashboard service.

M3 Manage Integrations

Click the “Use Integrations” button on the Dashboard modal.

M3 Dashboard

In the pop-up modal, select “New Service” and click the Continue button.

M3 New Integration

Follow similar steps to create the service by filling in the:

  1. Name

  2. Cloud

  3. Region

  4. Service Plan (Startup-1 is OK)

  5. And then click the Create and enable button.

M3 create new Grafana Integration M3 create new Grafana Integration

A new Grafana service will now be starting up and automatically connect to the M3 database to display metrics.

Click on the name of the service to navigate to the new service.

M3 navigate to new Grafana Integration

Once the service is running, click on the Service URI and login with the user / password from the connection information.

Grafana Service Login

Visualizing metrics#

Now to what we all have been waiting for, the Metrics!

In the Grafana dashboard, click the Explore tab.

Grafana Explore

Select your M3 service as the data source from the drop down menu at the top of the page. Click the metrics browser, select cpu_usage_user, and then click the “Use Query” button.

Grafana Explore for M3

The chart displayed below represents the CPU of the MacBook.

Grafana Metrics for M3

Tear Down At the terminal, press Ctrl+C to stop the Telegraf agent. Then, delete your M3 and Grafana services within the Aiven Console.