Send data from Telegraf to Axiom This page explains how to send data from Telegraf to Axiom.
Telegraf is an open-source, plugin-driven agent that collects metrics and events from your systems, services, and apps. To send the data that Telegraf collects to Axiom, use the HTTP output plugin of Telegraf.
Set up the Telegraf configuration file based on the Telegraf documentation .
In the Telegraf configuration file, use the HTTP output plugin with the following configuration. For more information on the plugin, see the Telegraf documentation .
[[ outputs . http ]]
url = "https://AXIOM_DOMAIN/v1/ingest/DATASET_NAME"
method = "POST"
content_encoding = "gzip"
data_format = "json"
json_transformation = '[metrics.{"_time": timestamp, "name": name, "tags": tags, "fields": fields}]'
[ outputs . http . headers ]
Content-Type = "application/json"
Authorization = "Bearer API_TOKEN"
Replace AXIOM_DOMAIN with the base domain of your edge deployment. For more information, see Edge deployments .
Replace API_TOKEN with the Axiom API token you have generated. For added security, store the API token in an environment variable.
Replace DATASET_NAME with the name of the Axiom dataset where you send your data.
Keep the json_transformation setting. It sends each metric as a separate event and sets the _time field to the time when Telegraf collects the metric. Without this setting, Telegraf sends all metrics of a flush in one JSON object, and Axiom stores them as a single event.
The following example collects CPU and memory metrics, changes the host tag with a processor plugin, and sends the data to Axiom:
# Input Plugins
[[ inputs . cpu ]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[ inputs . mem ]]
# No specific configuration required
# Processor Plugins
[[ processors . regex ]]
namepass = [ "cpu" , "mem" ]
[[ processors . regex . tags ]]
key = "host"
pattern = "(.*)"
replacement = "${1}-processed"
# Output Plugins
[[ outputs . http ]]
url = "https://AXIOM_DOMAIN/v1/ingest/DATASET_NAME"
method = "POST"
content_encoding = "gzip"
data_format = "json"
json_transformation = '[metrics.{"_time": timestamp, "name": name, "tags": tags, "fields": fields}]'
[ outputs . http . headers ]
Content-Type = "application/json"
Authorization = "Bearer API_TOKEN"
To start Telegraf with the configuration file, run the following command:
telegraf --config telegraf.conf
Each metric arrives in Axiom as a separate event with the following fields:
Field Description nameName of the metric. For example, cpu or mem tagsTags of the metric. For example, tags.host and tags.cpu fieldsValues of the metric. For example, fields.usage_user and fields.used_percent
For example, the following query charts the average user CPU usage over time:
[ 'DATASET_NAME' ]
| where name == 'cpu' and [ 'tags.cpu' ] == 'cpu-total'
| summarize avg ([ 'fields.usage_user' ]) by bin_auto (_time)