content/telegraf/controller/reference/architecture.md
{{% product-name %}} is a standalone application that provides centralized management for Telegraf agents. It runs as a single binary that starts two separate servers: a web interface/API server and a dedicated high-performance heartbeat server for agent monitoring.
When you run the Telegraf Controller binary, it starts four main subsystems:
8888)8000)8888)
/)/api/*)8000)
The dual-server architecture separates high-frequency heartbeat traffic from regular management operations, ensuring that the web interface remains responsive even under heavy agent load.
{{% product-name %}} configuration is controlled through command options and environment variables.
| Command Option | Environment Variable | Description |
|---|---|---|
--port | PORT | API server port (default is 8888) |
--heartbeat-port | HEARTBEAT_PORT | Heartbeat service port (default: 8000) |
--database | DATABASE | Database filepath or URL (default is SQLite path) |
--ssl-cert | SSL_CERT | Path to SSL certificate |
--ssl-key | SSL_KEY | Path to SSL private key |
To use environment variables, create a .env file in the same directory as the
binary or export these environment variables in your terminal session.
{{% product-name %}} automatically selects the database type based on the
DATABASE string:
Example PostgreSQL configuration:
DATABASE="postgresql://user:password@localhost:5432/telegraf_controller"
{{< diagram >}}
flowchart LR
T["Telegraf Agents
(POST heartbeats)"] --> H["Port 8000
Heartbeat Server"]
H --Direct Write--> D[("Database")]
W["Web UI/API
"] --> A["Port 8888
API Server"] --View Agents (Read-Only)--> D
R["Rust Scheduler
(Agent status updates)"] --> D
{{< /diagram >}}
Agents send heartbeats:
Telegraf agents with the heartbeat output plugin send POST requests to the
dedicated heartbeat server (port 8000 by default).
Heartbeat server processes the heartbeat:
The heartbeat server is a high-performance Rust-based HTTP server that:
POST request at /agents/heartbeatinstance_id in the heartbeat
payload.Heartbeat server writes directly to the database:
The heartbeat server uses a Rust NAPI module that:
sqlx (Rust SQL library) to write directly to the databaseThe Rust module performs these operations:
last_seen timestampAPI layer reads agent data:
The API layer has read-only access for agent data and performs the following actions:
GET /api/agents - List agentsGET /api/agents/summary - Agent status summaryThe API never writes to the agents table. Only the heartbeat server does.
The Web UI displays updated agent data:
The web interface polls the API endpoints to display:
The background scheduler evaluates agent statuses:
Every 60 seconds, a Rust-based scheduler (also part of the NAPI module):
last_seen timestamps against the agent's assigned reporting ruleAn agent requests a configuration:
Telegraf agents request their configuration from the main API server
(port 8888):
telegraf --config "http://localhost:8888/api/configs/{config-id}/toml?location=datacenter1&env=prod"
The agent makes a GET request with:
text/x-toml or application/octet-stream
for downloadThe API server receives request:
The API server on port 8888 handles the request at
/api/configs/{id}/toml and does the following:
Accept header to determine response formatThe application retrieves the configuration from the database:
{{% product-name %}} fetches configuration data from the database:
Last-Modified header{{% product-name %}} substitutes parameters:
{{% product-name %}} processes the TOML template and replaces parameters
with parameter values specified in the GET request.
{{% product-name %}} sets response headers:
Telegraf uses the Last-Modified header to determine if a configuration
has been updated and, if so, download and use the updated configuration.
{{% product-name %}} delivers the response:
Based on the Accept header:
{{< tabs-wrapper >}} {{% tabs "medium" %}} text/x-toml (TOML) application/octet-stream (Download) {{% /tabs %}} {{% tab-content %}}
HTTP/1.1 200 OK
Content-Type: text/x-toml; charset=utf-8
Last-Modified: Mon, 05 Jan 2025 07:28:00 GMT
[agent]
hostname = "server-01"
environment = "prod"
...
{{% /tab-content %}} {{% tab-content %}}
<!----------------------------- BEGIN DOWNLOAD ---------------------------->HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="config_name.toml"
Last-Modified: Mon, 05 Jan 2025 07:28:00 GMT
[agent]
hostname = "server-01"
...
{{% /tab-content %}} {{< /tabs-wrapper >}}
(Optional) Telegraf regularly checks the configuration for updates:
Telegraf agents can regularly check {{% product-name %}} for configuration
updates and automatically load updates when detected. When starting a
Telegraf agent, include the --config-url-watch-interval option with the
interval that you want the agent to use to check for updates—for example:
telegraf \
--config http://localhost:8888/api/configs/xxxxxx/toml \
--config-url-watch-interval 1h
{{% product-name %}} uses reporting rules to determine when agents should be marked as not reporting:
Access reporting rules via:
GET /api/reporting-rules