Getting Started with Telegraf

What is Telegraf?

Telegraf is an open-source server agent for collecting and reporting metrics. It can be used to collect a variety of metrics such as system statistics, application metrics, and event logs from spacecraft, drones, etc. Telegraf is highly extensible, with a plugin-driven architecture that allows it to support a wide range of input and output formats.

Common Uses of Telegraf

Telegraf is commonly used for:

  • System Monitoring: Collecting system-level metrics such as CPU usage, memory usage, disk I/O, and network statistics.
  • Application Monitoring: Gathering metrics from various applications and services, including databases, web servers, and custom applications.
  • Data Transformation: Applying transformations to the collected data before sending it to the desired output.
  • Metric Reporting: Sending collected metrics to various backends such as Nominal

Sending Data to Nominal

  1. Create a Nominal Data Source via the Python client.
  2. Log in to Nominal and copy the Write RID for the connection that was just created.
  3. Provision a Nominal API key by navigating to Org Settings in the Nominal platform.
  4. Substitue your Write RID and API Key into the following example telegraf file and get started.
1# Global agent configuration
2[agent]
3 interval = "1s" # How often to gather metrics
4 round_interval = true
5 metric_batch_size = 1000
6 metric_buffer_limit = 10000
7 collection_jitter = "0s"
8 flush_interval = "1s"
9 flush_jitter = "0s"
10 precision = "1ns"
11 debug = false
12 quiet = false
13
14# Example input plugin for reading CPU stats
15[[inputs.cpu]]
16 ## Whether to report per-cpu stats or not
17 percpu = true
18 ## Whether to report total system cpu stats or not
19 totalcpu = true
20 ## If true, collect raw CPU time metrics
21 collect_cpu_time = false
22 ## If true, compute and report the sum of all non-idle CPU states
23 report_active = false
24 ## If true and the info is available then add core_id and physical_id tags
25 core_tags = false
26
27# http output for streaming to Nominal
28[[outputs.http]]
29 url = "https://api.gov.nominal.io/api/storage/writer/v1/telegraf/$DATASOURCE_RID"
30 data_format = "json"
31 content_encoding = "gzip"
32 json_timestamp_units = "1ns"
33 flush_interval = "3s"
34 [outputs.http.headers]
35 Content-Type = "application/json"
36 Authorization = "Bearer $YOUR_API_TOKEN"

Note: Telegraf also supports embedding secrets such as your API token via the secrets store function